> From: Hancke Patrick [mailto:[EMAIL PROTECTED] 

[...]
> 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to