Configuration for logging application block

Topics: Logging Application Block
Jun 27, 2007 at 3:51 PM

Is it possible to specify the configuration for the Logging application block in a separate file without using the default application configuration file?. If so, could you please provide a code sample of how to initialize the Logger using this method.


Jun 28, 2007 at 1:53 AM

Here is a rough sample to get you started:

FileConfigurationSource sourceConfig = new FileConfigurationSource("YourCustomerConfigFile.exe.config");
LogWriterFactory factory = new LogWriterFactory(sourceConfig);
LogWriter writer = factory.Create();

LogEntry log = new LogEntry();
log.Message = "Log this message";
log.Categories = new string[] { "Installation" };
log.Priority = 1;
log.EventId = 1;
log.Severity = TraceEventType.Information;
log.Title = "This message Title";
log.ExtendedProperties = null;


Basically I dont think you can directly use the Logger facade (but it would be trivial to wrap this your self).

Hope this helps and gets you to the point you need to be,