ATTENTION: I've decided to put the upgrade on hold due to a compatibility issue of our server environment with the latest CS installer package. CS 2008 now requires SQL Server 2005 as the backend DB but our database server currenlty has SQL Server 2000 installed on it. I'll resume the upgrade once I figure out when Telligent is releasing a patch to the schema compatibility issue. For now, we will continue to use the old version of CS while waiting for the said patch. If you have any questions about this process, please don't hesitate to post them on our forums and I'll answer them as soon as I can. Thanks for your patience and support guys! I'll let you know as soon as this is resolved. - Keith Rull

log4net is not logging!

I have been using log4net for a year and a half now and there are scenarios where I'm expecting it to log some data only to find out that it's not logging.  I know two possible reasons of log4net not logging:

1.  It is not yet configured to log.

I am configuring log4net through the XML configuration files of .NET (not programmatically) and I always forget to include the

[assembly: XmlConfigurator(Watch = true)]

line in the assembly containing the starting entry of the application (windows application project or the web application project and not the class libraries).

 2.  The first call to LogManager.GetLogger was not coming from the assembly containing the log4net configurations.

Normally, .NET applications are structured with Data, Core, Presentation, Web assemblies.  log4net configurations are specified in the web.config of the Web project.  If the first call to LogManager.GetLogger was coming not from the Web assembly (Core, Data, or Presentation), you probably wouldn't get any logs.  From the log4net documentation "When should I log my first message":

The simple answer is as soon as possible. The long answer is more complex.

If you are configuring log4net programmatically, i.e. by calling the XmlConfigurator.Configure method then you should do so before you begin logging and it is reasonable to do this very soon after application start.

If you are configuring log4net by specifying assembly level attributes on your assembly then the configuration will be loaded once the first call to the LogManager.GetLogger is made. It is necessary that the first call to LogManager.GetLogger made during the process (or AppDomain) is made from the assembly that has the configuration attributes. Log4net will look only once and only on the first calling assembly for the configuration attributes.


Posted Jul 05 2007, 03:32 PM by jokiz

Add a Comment

(required)  
(optional)
(required)  
Remember Me?

Enter the numbers above:

Copyright DevPinoy 2005-2008