View Full Version : what is the proper way to disable spring.net logging?
Anonymous
03-04-2005, 06:39 PM
If I would like to temporarily disable spring.net logging, what is the proper way to modify my log4net config file?
Mark Pollack
03-05-2005, 05:12 PM
Hi,
There are many ways to configure log4net, refer to the log4net manual (http://logging.apache.org/log4net/release/manual/configuration.html) or a an OnDotNet (http://www.ondotnet.com/pub/a/dotnet/2003/06/16/log4net.html) article for the more details.
A simple recipe you can use is in your .NET application configuration file add a log4net custom configuration section handler
<configSections>
<section name="log4net"
type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
and also
<log4net>
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender" >
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%d [%t] %-5p %c - %m%n"/>
</layout>
</appender>
<root>
<level value="WARN" />
<appender-ref ref="ConsoleAppender" />
</root>
</log4net>
Depending on how much you really want to suppress log4net you can set the level to WARN, ERROR, FATAL or OFF. I'd recommend setting it to WARN or ERROR.
You then enable the logging either by putting the following attribute in the assembly
[assembly: log4net.Config.DOMConfigurator()]
and making a standard log4net logging call somewhere during the app startup before the spring assemblies have been loaded or instead configure explicity using
log4net.Config.DOMConfigurator.Configure();
Cheers,
Mark
MNBob
05-06-2005, 02:20 PM
Thanks, but I only want to disable Spring.NET logging, not all logging.
I tried:
<logger name="Spring.*">
<level value="OFF" />
</logger>
but that doesn't seem to work.
Mark Pollack
05-06-2005, 02:59 PM
Hi Bob,
The .* is implied so just add
<root>
<level value="DEBUG"/>
<appender-ref ref="ConsoleAppender"/>
</root>
<logger name="Spring">
<level value="OFF"/>
</logger>
I'd recommend not turning it off completely but keeping it at the warning or error level.
Cheers,
Mark
MNBob
05-13-2005, 08:27 PM
This is really just a general .NET configuration question. I downloaded the current log4net version which breaks my build because Spring.NET is using an older version. What is the proper way to make my application (using an updated log4net) co-exist with Spring (using the older version of log4net)?
Mark Pollack
05-14-2005, 04:03 PM
Hi,
There is some info about this on the log4net mailing listhere (http://marc.theaimsgroup.com/?l=log4net-user&m=111367361428762&w=3).
Cheers,
Mark
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.