Config file for Logging application

Topics: Logging Application Block
Jul 2, 2009 at 1:07 AM

I have a .NET solution with two projects: one is library module for custom logging and another is web application that uses logging feature from another project.

What I am trying to do is have alll logging functionality and all required logging and related configuratoin in first module and web application just use that.

Is that possible ? I  tried and didn't work. How can we do that ?

Jul 2, 2009 at 5:02 AM
Edited Jul 2, 2009 at 5:10 AM

Do you really need to have the configuration for logging in the class library?  Class libraries don't own configurations that's why you didn't get it to work.  It should be placed in your executable which is your web project.  If you really want to keep your logging configuration in your class library, you can have your web.config use the configSource attribute to point to the config file in the class library.  Refer to this thread -

You can also do this through API:

IConfigurationSource sourceConfig = new FileConfigurationSource("logging.config");
LogWriterFactory factory = new LogWriterFactory(sourceConfig);
LogWriter writer = factory.Create();

LogEntry log = new LogEntry();
log.Message = "log this";
log.Categories = new string[] { "Installation" };


 The FileConfigurationSource points to the config of your class library.


Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.

Jul 2, 2009 at 2:53 PM

Thanks for your reply.

I am trying to encapsulate everything related to logging in the class library with custom trace listener, custom logger, custom logentry and related config file and I want Web App to just call custom logger class and its method.

Jul 3, 2009 at 4:02 AM

Do you have any other specific question on this?  I'm not sure if you decided to use any of the 2 suggestions I made.


Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.