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.