Saturday, February 04, 2012
 
The best way to analyze your logs! Minimize
 Log4Net Mail archive   

The Log4Net mailing list is a great source of information about using log4Net, in this forum we collect all the messages in the log4net user list and some selected threads from the developer list.

Subject: DEBUG vs INFO
Prev Next
You are not authorized to post a reply.

Author Messages
Graham Walsh

02/25/2009 2:33 PM  

Hi,

I just switch from DEBUG to INFO in our application logging and the
difference is pretty much stunning. E.G. our perf has gone from 23
seconds down to 14 because of the change. Is this a known issue. i.e.
debug log level is expected to impose this kind of overhead.

Thanks

Graham

Walden H. Leverich

02/25/2009 3:31 PM  

Graham,

That's not a log4net issue as much as it's an issue in your application.
Sounds like your application (like many) makes lots of log.Debug()
calls, to log, um, debug information. By switching the logging from
DEBUG to INFO you've stopped all those log entries from being written to
disk. Even more, if your app developers were smart about it, they
checked the IsDebugEnabled property before making the log.Debug() call,
so you're not even evaluating the parms to that call, and sometimes that
can be quite expensive.

So, it's a "known issue" that logging more stuff takes more time, but I
wouldn't call it a bug.

-Walden

--
Walden H Leverich III
Tech Software
(516) 627-3800 x3051
WaldenL@TechSoftInc.com
http://www.TechSoftInc.com

Quiquid latine dictum sit altum viditur.
(Whatever is said in Latin seems profound.)

Michael Schall

02/25/2009 8:36 PM  
What appenders are you using? I assume one of them is the rolling file appender?  How large is the log file produced with the setting at DEBUG vs INFO? 

If you need to keep the debug information you can look at the BufferingForwardingAppender.  The following will buffer 255 messages before writing to the file, unless there is a WARN or higher message, then the buffer is flushed immediately.  This should hopefully let the error message that crashes the system still make it to the log file.:)

 I don't know how your loggers are setup, but you can turn off at that level as well.  

<log4net>

<appender name="BufferingForwardingAppender" type="log4net.Appender.BufferingForwardingAppender" >
<bufferSize value="255" />
<lossy value="false" />
<evaluator type="log4net.Core.LevelEvaluator">
<threshold value="WARN"/>
</evaluator>
<appender-ref ref="RollingFile" />
</appender>
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
<file value="..\..\log\web.log" />
<appendToFile value="true" />
<maximumFileSize value="100MB" />
<maxSizeRollBackups value="-1" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%5level [%date] [%thread] %-30.30logger{2} %message%newline" />
</layout>
</appender>
<root>
<level value="DEBUG" />
<appender-ref ref="BufferingForwardingAppender" />
</root>
</log4net>
Graham Walsh

02/26/2009 8:22 AM  
Thanks Walden for the reply, that makes total sense. The error is on our part (we're in production with debug on as its a greenfield project).
 
 
This second reply to my question brings me to my point. What was actually happening (and this is speculation), is that my code changes related to performance we're having no impact on the results/times of our processing. I had introduced multi-threading in three or four areas of the code to reduce bottlenecks. They weren't having any impact. What I THINK was happening is that the DEBUG log messages were causing disk writes which were taking time and thus causing thrashing/lots of context switching. The new threads were working alright but kept being interrupted, hence the lack of any performance improvement with my changes. 
 
With INFO on (and some changes to log level in key parts of the code) , the users will not be aware of the changes in log level. In addition I intend to fall back onto Michaels suggestion below. i.e. if they absolutely MUST have logging at DEBUG level, I'll try have it bufferred as indicated below. 
 
thanks much for the replies.
 
G
 
Graham Walsh

02/26/2009 9:09 AM  
sorry, but I'm having trouble with one part of this config, I always do. I have taken the BufferingForwardingAppender and put it in place, its works a treat.
 
I've also got another appender which is used to display log output in the GUI window. Now I want BufferingForwardingAppender  (which logs to file) to log at debug level but my other appender (RichTextFormAppender) to log at just INFO level. I can't get this working though.
 
My (messy) log4net stuff looks like this, could anybody let me know how I can get the two levels of logging in place? Once thats done, I'm water tight in terms of delivery
 
thanks much
 
Graham
 
 

<log4net>

<appender name="BufferingForwardingAppender" type="log4net.Appender.BufferingForwardingAppender" >

<bufferSize value="255" />

<lossy value="false" />

<evaluator type="log4net.Core.LevelEvaluator">

<threshold value="DEBUG"/>

</evaluator>

<appender-ref ref="RollingFile" />

</appender>

<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">

<file value="logs/NewLogFile.log" />

<appendToFile value="true" />

<maximumFileSize value="100MB" />

<maxSizeRollBackups value="-1" />

<layout type="log4net.Layout.PatternLayout">

<conversionPattern value="%5level [%date] [%thread] %-30.30logger{2} %message%newline" />

</layout>

</appender>

<appender name="MainFormRichTextAppender" type="log4net.Appender.RichTextBoxAppender">

<appendToFile value="true" />

<maximumFileSize value="250000KB" />

<maxSizeRollBackups value="2" />

<layout type="log4net.Layout.PatternLayout">

<conversionPattern value="%date [%-2thread] %-5level %-70logger - %message%newline" />

</layout>

<code lang="XML" escaped="true">

<mapping>

<level value="DEBUG" />

<textColorName value="DarkGreen" />

<fontFamilyName value="Microsoft Sans Serif"/>

<pointSize value="6.75" />

</mapping>

<mapping>

<level value="INFO" />

<textColorName value="Black" />

<fontFamilyName value="Microsoft Sans Serif"/>

<pointSize value="6.75" />

</mapping>

<mapping>

<level value="WARN" />

<textColorName value="Blue" />

<fontFamilyName value="Microsoft Sans Serif"/>

<pointSize value="6.75" />

</mapping>

<mapping>

<level value="ERROR" />

<textColorName value="Red" />

<!--<bold value="true" />-->

<fontFamilyName value="Microsoft Sans Serif"/>

<pointSize value="6.75" />

</mapping>

<mapping>

<level value="FATAL" />

<textColorName value="Black" />

<fontFamilyName value="Microsoft Sans Serif"/>

<pointSize value="6.75" />

</mapping>

</code>

</appender>

<root>

<level value="DEBUG" />

<appender-ref ref="BufferingForwardingAppender" />

<appender-ref ref="MainFormRichTextAppender"/>

</root>

 
Graham Walsh

02/26/2009 9:33 AM  
Sorry, ignore that last email, its actually working as I want.
 
Does anybody know if its possible to configure a RichTextBoxAppender (log output goes to a rich text box, its a contribution by another engineer not the original author(s) of log4net, (I think). If I can get buffering in place for the RichTextBox appender, I will have the same output but without the overhead (i.e. DEBUG info at no price.. so to speak).
 
thanks
 
Graham
 
Walden H. Leverich

02/26/2009 5:27 PM  

> DEBUG info at no price.. so to speak

 

Can't help on the buffering, but your comment above isn't necessarily correct at any rate. It depends on where the performance his of the Debug() call is. Sure there's a hit on writing the log to disk, and the buffering helps there, but there is also the hit of generating the text for the debug call in the first place. There's the method call, there's the string concatenation, there's likely numerous .ToString() calls, if you're looking for line#s in the log file then there's the (high) cost of getting that information. None of these issues will be removed by buffering the write to disk. I'm not saying buffing won't buy you something, it will. But it doesn't give you DEBUG at no price.

 

-Walden

 

--

Walden H Leverich III

Tech Software

(516) 627-3800 x3051

WaldenL@TechSoftInc.com

http://www.TechSoftInc.com

 

Quiquid latine dictum sit altum viditur.

(Whatever is said in Latin seems profound.)

You are not authorized to post a reply.
Forums > Log4Net > Log4Net Mail archive > DEBUG vs INFO



ActiveForums 3.7

 

 

 

 

 

 

 

 

Log4Net Dashboard

Log analysis and monitoring made easy!

Log4Net Dashboard is a log viewer that can read log statements from a variety of logging output targets.

You can download a free developer version.

  

Check it out!

On the demonstration site you can try it  with live data.demo.l4ndash.com - Try Log4Net Dashboard with live data

The mail archive is a copy of all the mail sent to the mail address: log4net-user@logging.apache.org, organized as a forum.

If you would like to participate in the mail list, send a mail to log4net-user-subscribe@logging.apache.org.

More information about the mailing list is available on: http://logging.apache.org/log4net/support.html

 

A complete topic list is available and can be viewed here (warning, it takes some time to load)

 

Copyright 2005-2008 by FaktNet AS Terms Of Use Privacy Statement