logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Young, Jason \(GE Infrastructure\)" <Jason.Yo...@ge.com>
Subject RE: Change logging level with a trigger
Date Thu, 25 Aug 2005 17:50:39 GMT
If I'm understanding the syntax right, it looks like I can use the xml
below.  However, it does not work.  It looks like it should log all INFO
messages and above regardless of having an error.  It should also log
the last 512 messages if there is a warn or above.  Am I understanding
it correctly?

		<appender name="BFA"
type="log4net.Appender.BufferingForwardingAppender" >
			<bufferSize value="512" />
			<lossy value="true" />
			<evaluator type="log4net.Core.LevelEvaluator">
				<threshold value="WARN"/>
			</evaluator>
			<lossyEvaluator
type="log4net.Core.LevelEvaluator">
				<threshold value="INFO"/>
			</lossyEvaluator>
			<appender-ref ref="RollingFiles" />		
		</appender>

    <!-- Setup the root category, add the appenders and set the default
level -->
    <root>
			<level value="DEBUG" />
			<appender-ref ref="BFA" />
		</root> 

-----Original Message-----
From: Nicko Cadell [mailto:nicko@neoworks.com] 
Sent: Thursday, August 25, 2005 12:08 PM
To: Log4NET User
Subject: RE: Change logging level with a trigger

Ok, all you are missing is a LossyEvaluator that will catch the Info and
Warn event when they are about to be lost from the buffer and write the
to the output.
Just after your <evaluator> add the following:

<lossyEvaluator type="log4net.Core.LevelEvaluator">
  <threshold value="INFO"/>
</lossyEvaluator>

Nicko

> -----Original Message-----
> From: Young, Jason (GE Infrastructure) [mailto:Jason.Young@ge.com]
> Sent: 25 August 2005 17:43
> To: Log4NET User
> Subject: RE: Change logging level with a trigger
> 
> Sorry for the abiguity.  I want the messages to go to a file.
> 
> To reiterate, I want the log to contain all info messages and above.
> When an error occurs, I want additional information, all the way down 
> to the debug level.  So if an error occurs, I will have the last 500 
> log messages that will tell me what led up to that event.
> 
> I really appreciate any help you can provide.
> 
> Here is what I have so far:
> <?xml version="1.0" encoding="utf-8" ?> <log4net>
>     
>     <!-- Define our output appender(s) -->
>     <appender name="RollingFiles"
> type="log4net.Appender.RollingFileAppender">
>         <param name="File" value="Log.txt" />
>         <param name="AppendToFile" value="true" />
> 
>         <param name="MaxSizeRollBackups" value="20" />
>         <param name="MaximumFileSize" value="10MB" />
>         <param name="RollingStyle" value="Size" />
>         <param name="StaticLogFileName" value="true" />
> 
>         <layout type="log4net.Layout.PatternLayout">
>             <param name="Header" value="***** Log Started *****\r\n"/>
>             <param name="Footer" value="***** Log Ended *****\r\n"/>
>             <param name="ConversionPattern" value="%d [%t] %-5p %c 
> [%x]
> - %m%n" />
>         </layout>
>     </appender>
>     
> 		<appender name="BFA"
> type="log4net.Appender.BufferingForwardingAppender" >
> 			<bufferSize value="512" />
> 			<lossy value="true" />
> 			<evaluator type="log4net.Core.LevelEvaluator">
> 				<threshold value="ERROR"/>
> 			</evaluator>
> 			<appender-ref ref="RollingFiles" />		
> 		</appender>
> 
>     <!-- Setup the root category, add the appenders and set the 
> default level -->
>     <root>
> 			<level value="INFO" />
> 			<appender-ref ref="RollingFiles" />
> 		</root>
> 		
> 		<!--
> 			Send all messages to the Buffering Forwarding
Appender so that it 
> can
> 			log the debug messages when it
> encounters an ERROR level message.
> 		-->
> 		<logger name="root">
> 			<level value="DEBUG" />
> 			<appender-ref ref="BFA" />
> 		</logger>
> </log4net>
> 
>  
> 
> -----Original Message-----
> From: Nicko Cadell [mailto:nicko@neoworks.com]
> Sent: Thursday, August 25, 2005 10:04 AM
> To: Log4NET User
> Subject: RE: Change logging level with a trigger
> 
> Jason,
> 
> > We only want to log info messages and above, but if a
> warning or above
> 
> > is encountered, we want it to output the last x number of messages.
> 
> When you say last x messages, do you mean of only Info and above?
> If so then just set the logger level to Info.
> 
> <root>
> 	<level value="Info" />
> 	<appender-ref ...>
> </root>
> 
> 
> > The buffered file appender looks like it almost does this, but not 
> > quite.
> 
> Where do you want the log messages to go? file, email etc...
> 
> 
> > We've also been able to log all messages, but send an email
> on error
> > messages with the buffer.
> 
> If you want to trigger sending the buffer on Warn events then you need

> to specify a threshold value on the Evaluator of the 
> BufferingForwardingAppender.
> 
> <evaluator type="log4net.Core.LevelEvaluator">
> 	<threshold value="Warn" />
> </evaluator>
> 
> 
> > Does someone have an example config file that I could see?
> > 
> > If you need more clarification, or want to see where I got stuck, 
> > please let me know.
> 
> Why don't you post the log4net configuration you currently have.
> 
> Cheers,
> Nicko
> 
> > 
> > Thanks,
> > Jason
> > 
> 
> 


Mime
View raw message