Jay Carlton
Jay Carlton

Reputation: 1178

Can I use a custom build logger side by side with the standard logger?

I have a custom build logger based on the BasicFileLogger example at MSDN. It's working nicely, but if I want to use it on the build server, I need its output to be in addition to what's already output with the default logger, but written to a separate file (and with different options). To make matters slightly more interesting, the existing build logging scheme creates a new file each time, but I want mine to append to a file. (If it matters, we build several projects on the command line via separate invocations of msbuild.exe rather than using a master solution file).

One approach I'm looking at is encapsulating a class that implements the default logger behavior with mine, which will get the first crack at the warning and error events so I can write them out to my file in my format, but then forward them to the inner class to write them out to the file specified with /filelogger. The first question is, is this necessary? If so, can I pass two different log file names on the command line, or would one of them need to be set "magically" (e.g. with an environment variable) and the other passed with /filelogger. I think this is the general approach used in this article.

Upvotes: 1

Views: 221

Answers (1)

Nicodemeus
Nicodemeus

Reputation: 4083

Certainly!

Check out the command line switches here. Note the "Append" switch to enable the requested behavior.

I see that link provides this sample to control the console output with the custom logger:

MSBuild /nologo /noconsolelogger /logger:SimpleLogger.dll /verbosity:Detailed

You can have various loggers running using /cl to manage the console logger and /flN for the various file loggers.

msbuild.exe /fl1 /flp1:Verbosity=diag;logfile=msbuild.log;append;

Upvotes: 1

Related Questions