I am trying to use MetroLog to write log files for a Windows Store application. I've followed the very sparse documentation (basically, copied code from the Windows 8 sample), but I'm not getting anything logged anywhere that I can tell.
I started with a basic Windows 8.1 Store app (using the "Split App" template), and in the constructor for my
var logger = LogManagerFactory.DefaultLogManager.GetLogger<App>();
logger.Trace("Sample MetroLog Trace Message");
logger.Debug("Sample MetroLog Debug Message");
logger.Info("Sample MetroLog Info Message");
logger.Warn("Sample MetroLog Warn Message");
logger.Error("Sample MetroLog Error Message");
logger.Fatal("Sample MetroLog Fatal Message");
For anyone else that runs into this problem:
It appears that, by default, the
LogConfiguration object (including the default one) is turned off. None of the MetroLog samples seem to reflect this but in order to make any logging happen, I had manually enable it.
I changed my code to this:
var configuration = new LoggingConfiguration(); #if DEBUG configuration.AddTarget(LogLevel.Trace, LogLevel.Fatal, new DebugTarget()); #endif configuration.AddTarget(LogLevel.Trace, LogLevel.Fatal, new StreamingFileTarget()); configuration.IsEnabled = true; LogManagerFactory.DefaultConfiguration = configuration;
And it's now working.