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.
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.
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.
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.
August 26th, 2008 at 10:33 #Neil Sleightholm
Thanks for the info, I think I will use LOGVERBOSE included via a preprocessor condition:
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
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…
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);
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?
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.
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.
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.
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!
September 4th, 2008 at 04:57 #Neil Sleightholm
Bug reported: Id=642714
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:
September 18th, 2008 at 18:37 #Tony Juricic
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.