0

I'm still newbie and still learning how to do a good installer, but I have some questions again : How can I print logs session?

I have for example :

 [CustomAction]
    public static ActionResult CheckDatabaseExist(Session session)
    {

        try
        {

            session.Log("CheckDatabaseExist: Begin");

            var builder = getSqlConnectionsStringBuilder(session);
            using (var connection = new SqlConnection(builder.ConnectionString))
            {

                SqlCommand someCommand = new SqlCommand();
                someCommand.Connection = connection;
                someCommand.Parameters.Add("@databaseName", SqlDbType.NChar).Value = session.CustomActionData["DATABASE_NAME"];

                using (var command = new SqlCommand(string.Format("SELECT db_id('@databaseName')") ,connection))
                {

                      session.Log("command is: " + command);
                      if (command.ExecuteScalar() != DBNull.Value)
                      {
                          session["DATABASE_EXISTED"] = "1"; // existed
                      }
                      else
                      {
                          session["DATABASE_EXISTED"] = string.Empty; // did not exist
                      }

                }
            }

            session.Log("CheckDatabaseExist: End");
        }
        catch (Exception ex)
        {
            session.Log("CheckDatabaseExist: exception: {0}", ex.Message);
            throw;
        }


        return ActionResult.Success;
    }

I want to have all my log in a file?

I tried this command line :

msiexec /i DatabaseScriptsInstall.msi /L*V log.txt

But I do not have the session log...

Any idea?? It will be very helpful for me, I didn't find answer yet.

Thanks

Bob
  • 529
  • 1
  • 7
  • 28
  • Does the log say you are running the custom action in it? It should say something like `MSI (c) (50:3C) [10:59:23:794]: Doing action: ` and if it doesnt run it you would see `MSI (c) (50:E8) [10:59:41:953]: Skipping action: (condition is false)` – Brian Sutherland Sep 29 '16 at 21:20
  • Hi @BrianSutherland, Yes I have : `MSI (s) (C4:2C) [09:08:06:760]: Doing action: CheckDatabaseExist Action 09:08:06: CheckDatabaseExist. Action start 09:08:06: CheckDatabaseExist.` and I can see my properties changing... but not the log :( – Bob Sep 30 '16 at 07:27
  • 1
    It looks fine so I don't see why there would be no logs. very odd. That's how I would log something just session.Log("string"); Not sure why the logs aren't appearing for you =[ – Brian Sutherland Sep 30 '16 at 14:49
  • oh bad news for me ! I suppose, I've something different on my environment.... Did you build you MSI with a special behavior? I'm so hopeless – Bob Sep 30 '16 at 15:49
  • 1
    How are you running the custom action? According to [this](http://stackoverflow.com/questions/3494101/wix-c-sharp-custom-action-logging-not-working) you can't use logging from a control event (click a button and do a custom action based off the click). – Brian Sutherland Sep 30 '16 at 17:33
  • Okay !! I read this article, but I didn't understand as well. So, it's a workarround (a bad one)? Thanks a lot!!! I used the control event to publish it! I'll try to set my log in properties or can I use something else instead of the control event?? – Bob Oct 03 '16 at 08:16

0 Answers0