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.

16 Replies to “Verbose logging from WcaUtil”

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

  2. 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. 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. Thanks for the info, I think I will use LOGVERBOSE included via a preprocessor condition:

  5. 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:

    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. 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. 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. 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. 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. 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. 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. 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. 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:

  14. 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.

Comments are closed.