logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ferenc Toth" <ft...@eu.infobal.com>
Subject RE: log4j: dump wrap-around buffer of all log messages
Date Mon, 11 Aug 2003 13:23:56 GMT
> From: Hancke Patrick [mailto:Patrick.Hancke@siemens.com] 

[...]
> The wrap-around buffer (think of it as an array of let's say 500 log
> messages) contains at any moment, the last 500 log messages. 
> The idea is
> that the logger has 2 log levels: one which determines what 
> level is present
> in the log file (or std out or whatever), another which 
> determines at what
> level the internal wrap-around buffer is filled with 
> messages. This way, it
> is possible to let your application log at level INFO, while 
> the internal
> buffer keeps all messages of level DEBUG or higher. When an 
> exception is
> thrown, the user should have the ability to request a dump of 
> the buffer,
> such that the more detailed DEBUG messages are also present 
> in the log file
> to make debugging more easy.

Yes, possible. You have to implement a small appended built around
CyclicBuffer (found in some one of the log4j packages) and that's it.
Then you can use a log4j xml config file like this. This will send all
INFO and higher messages to "normal" appender and all debug messages
will land at the "debug" appender and you're free to handle those
messages in the CyclicBuffer as you like.

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">

	<appender name="debug"
class="ams.v9.logging.MyAppendedBuiltAroundCyclicBuffer">
		<whatever params I take/>
	</appender>

	<appender name="normal"
class="org.apache.log4j.DailyRollingFileAppender">
		<param name="File" value="logs\\server.log"/>
		<param name="DatePattern" value=".yyyy-ww"/>
		<filter class="org.apache.log4j.varia.LevelRangeFilter">
			<param name="LevelMin" value="INFO" />
		</filter>
	</appender>

	<root>
		<priority value="debug"/>
		<appender-ref ref="debug"/>
		<appender-ref ref="normal"/>
	</root>
</log4j:configuration>

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org


Mime
View raw message