logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stadelmann Josef" <josef.stadelm...@axa-winterthur.ch>
Subject AW: Logging with specialized logger for webapplication
Date Tue, 26 Jun 2012 09:14:25 GMT
There is a root logger; and there are loggers lower in the hierarchies.

Each logger needs appenders. (devices) where ever a message originates, 
as long as a logger is said that its additivity="false"> 
as long as the events logged by this logger are not propagated further to 
the root logger. That is what additivity="false" does.

in your case you need to log all events with log.debug("debug") at your 
special logger. With additivity="true" you allow that this logging events 
will make it to upper loggers in the hierarchies and after all reach the 
root logger

At the root logger you have an appender too, don't you?
This appender is now informed, to only log info, warning, error, fatal events only.

So make first sure that your special logger logs all events and that all events 
reach the root logger then filter at the root not with the logger but the appender 
of the root logger.


-----Urspr√ľngliche Nachricht-----
Von: garfield168 [mailto:garfield.15@gmx.de] 
Gesendet: Montag, 25. Juni 2012 14:06
An: log4j-user@logging.apache.org
Betreff: Logging with specialized logger for webapplication


We use WebSphere as application server which has the standard logging files
SystemOut.log and SystemErr.log.
I want to create a log4j configuration with a special logger "SpecialLogger"
which logs all debug/info/error messages to a special log file. Additionally
error messages should be logged to SystemErr.log but the debug/info messages
from this logger should not be logged to SystemOut.log (but other info
messages not from this logger should be logged).
Maybe there is a solution with additivity="false" and LevelRangeFilter but I
cannot get it work like described. 
Here is my last try:

<?xml version="1.0"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
    <appender name="stdout" class="org.apache.log4j.ConsoleAppender">
        <layout class="org.apache.log4j.PatternLayout">
  <appender name="SpecialLoggerAppender"
        <layout class="org.apache.log4j.SimpleLayout"/>
         <filter class="org.apache.log4j.varia.LevelRangeFilter">
	<logger name="SpecialLogger" additivity="false">
		<level value="error" />
		<appender-ref ref="SpecialLoggerAppender" />
        <level value="error"/>
        <appender-ref ref="stdout" />

Can someone help please?
Thanks in advance
View this message in context: http://old.nabble.com/Logging-with-specialized-logger-for-webapplication-tp34066057p34066057.html
Sent from the Log4j - Users mailing list archive at Nabble.com.

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

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

View raw message