I am using log4net in my .NET 3.5 console application and would like the log messages I generate to be seen in both the console standard out and the RollingFileAppender. The
In the app I inherited, there was the line:
<appSettings>
<add key="log4net.Internal.Debug" value="true"/>
Changing that to false
fixed the problem.
please look at log4net faq. they realy have all those common pitfalls you might encounter.
I just went through this same problem (which, unsurprisingly, is how I found this question).
Anyway, my problem, and possibly yours as well, was caused by a web/app config file setting of "<
log4net debug=true>
". Too obvious, right? I had pasted the skeleton of my app.config settings in from a web snippet, and had focused on the appenders, not really giving the root log4net element a second glance. But there you have it. This is in the FAQ, but again other things caught my eye and not this attribute.
If you have this in your code:
log4net.Config.BasicConfigurator.Configure();
Change it to:
log4net.Config.XmlConfigurator.Configure();
Please try to replicate the problem using a new project one step at the time (first reference log4net with no appender, then with the console appender, then with both appenders). If it shows the same behavior, please post the complete config of log4net.
Also you could try using the configuration samples from log4net Config Examples page.
Edit: This could be the cause of those messages: How do I enable log4net internal debugging.
set debug = false
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<log4net debug="false">
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="your file name" />
<appendToFile value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="10" />
<maximumFileSize value="10MB" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%-5p %d %5rms %-22.22c{1} %-18.18M - %m%n" />
</layout>
</appender>
<root>
<level value="DEBUG" />
<appender-ref ref="RollingLogFileAppender" />
</root>
</log4net>
</configuration>