Verbose logging from WcaUtil

WcaUtil is a static library of convenience functions for writing custom actions in native C++. One of the more useful functions is WcaLog, which writes messages into the Windows Installer log. The first argument to WcaLog is the level of the message:

  • LOGMSG_TRACEONLY: Written to the log only in debug builds for debugging custom actions.
  • LOGMSG_VERBOSE: Written to the log only when verbose logging is enabled.
  • LOGMSG_STANDARD: Always written to the log.

WcaLog considers verbose logging enabled whenever any of the following is true:

  • LOGVERBOSE property: There’s a property in your package named LOGVERBOSE, regardless of its value.
  • MsiLogging property: There’s a property in your package named MsiLogging that contains a V character.
  • Logging policy: The logging policy is set and contains a V character.

Otherwise, messages tagged with LOGMSG_VERBOSE will be ignored.

The second argument is a printf-style format string so there are a variable number of arguments (zero or more) after it which specify the values referred to in the format string. For example:

WcaLog(LOGMSG_VERBOSE, "App: %S found running, %d processes, setting ‘%S’ property.", wzApplication, cProcessIds, wzProperty);

Note that WcaLog uses ANSI strings for the format string and its arguments, so if you want to log a Unicode string, you need to use the %ls or %S field characters.

Posted in WiX at July 15th, 2008. Trackback URI: trackback
Tags:

16 Responses to “Verbose logging from WcaUtil”

  1. July 20th, 2008 at 12:15 #Tony

    Thanks for this Bob! I was just wondering why, enabling every known logging msiexec option, doesn’t log wca verbose messages.

  2. August 25th, 2008 at 15:14 #Neil Sleightholm

    Does running msiexec with “/L*v” enable verbose logging? Does this apply to all versions of Windows Installer? The MsiLogging documentation seems to imply this is for v4.0 or later.

  3. August 25th, 2008 at 19:41 #Bob Arnson

    MSI doesn’t process the /L*v in any way a CA can detect; that’s why we have the “backup” methods above. Before MSI 4.0, MsiLogging doesn’t do anything, but WcaUtil can still detect it.

  4. August 26th, 2008 at 10:33 #Neil Sleightholm

    Thanks for the info, I think I will use LOGVERBOSE included via a preprocessor condition:

  5. August 28th, 2008 at 11:35 #Neil Sleightholm

    I don’t seem to be getting verbose logging no matter what I do. I have set LOGVERBOSE in my MSI as follows:
    <Property Id=”LOGVERBOSE” Value=”1″ />
    I have set the logging policy:
    [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Installer]
    “Logging”=”voicewarmupx”
    “Debug”=dword:00000007

    and I start my install with the command line:
    msiexec /i Setup.msi /L*v Setup.log

    but I don’t see the verbose logging in my log file. I’m sure I am missing something really obvious and would appreciate your help. Thanks, Neil

  6. August 29th, 2008 at 11:59 #Bob Arnson

    Neil,

    Are you looking for verbose log messages from your own CAs or from a WiX CA? I remember stepping through the combinations when I added support for MsiLogging and it worked then…

  7. August 31st, 2008 at 09:53 #Neil Sleightholm

    They are all WiX CAs, the one I was look at recently was PermissionEx. The trace line I was expecting was from secureobj.cpp, WcaLog(LOGMSG_VERBOSE, “Securing Object: %S Type: %S User: %S”, pwzObject, pwzTable, pwzUser);

  8. September 1st, 2008 at 22:50 #Bob Arnson

    Neil,

    I tried to reproduce this with a sample for the CloseApp CA and couldn’t — its verbose messages showed up with any of the three options above. Is it possible the loop isn’t getting entered?

  9. September 2nd, 2008 at 07:54 #Neil Sleightholm

    I guess it is possible but the permissions are being set. I am doing this on Windows XP, with Installer v4.0 if that makes any difference. I have figured out what I was looking for now but if I get time I’ll try and debug PermissionEx to see what is happening.

  10. September 2nd, 2008 at 20:07 #Bob Arnson

    Neil,

    Hmmm…Well, I’m out of ideas at the moment. WcaLog should work the same way regardless of the CA calling it. … Oh wait. I can’t believe I didn’t see this: The logging you point out is in a deferred CA, so it’ll never see either property. That’s a hole we should plug…

    That said, the policy registry key should still be readable, even from a deferred CA. Any chance you’re running this on an x64 OS? If you’re using the 32-bit CA, the logger will be looking under HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Policies.

  11. September 3rd, 2008 at 05:54 #Neil Sleightholm

    I am not using 64 bit. I am using the logging policy in: [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Installer]. I copied the code from the user comment attached the link you put in your original post.

  12. September 3rd, 2008 at 20:10 #Bob Arnson

    Bummer. OK, please feel free to file a bug; I can’t promise to look at it this week (lots of other stuff going on) but I don’t want to conveniently forget about it!

  13. September 4th, 2008 at 04:57 #Neil Sleightholm

    Bug reported: Id=642714

  14. September 18th, 2008 at 18:35 #Tony Juricic

    I could have sworn that it worked for me at one time. However, I am having the same problem as Neil, only I enable verbose log in Debug builds like this:

  15. September 18th, 2008 at 18:37 #Tony Juricic

  16. September 20th, 2008 at 14:31 #Bob Arnson

    Eric provided a fix to let any immediate-mode logging “remember” the setting for later deferred WcaLog calls. It doesn’t change any issues with the policy setting, however.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>