Mikael,

I think your main problem here is that you cannot put the same logger name 
="xxx"  and have that xxx be the same string, to be able to seperate by logging 
level.    I think your only way would be to have multiple appenders that each 
have their own log file that are by log level.

This is the way to log org (3rd party) to Error for MAIN_LOG and INFO to DEBUG 
LEVEL:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">



    <!-- A time/date based rolling appender -->
    <appender name="MAIN_LOG" 
class="org.jboss.logging.appender.DailyRollingFileAppender">
        <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler" />
        <param name="File" value="logs/main.log" />
        <param name="Append" value="false" />
        <param name="Threshold" value="ERROR" />        
        
        <!-- Rollover at midnight each day -->
        <param name="DatePattern" value="'.'yyyy-MM-dd" />

        <layout class="org.apache.log4j.PatternLayout">
            <!-- The default pattern: Date Priority [Category] Message\n -->
            <param name="ConversionPattern" value="%d %-5p [%c] %m%n" />
        </layout>
    </appender>

    <!-- A time/date based rolling appender -->
    <appender name="DEBUG_LOG" 
class="org.jboss.logging.appender.DailyRollingFileAppender">
        <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler" />
        <param name="File" value="logs/debug.log" />
        <param name="Append" value="false" />
        <param name="Threshold" value="INFO" />
            
        <!-- Rollover at midnight each day -->
        <param name="DatePattern" value="'.'yyyy-MM-dd" />

        <layout class="org.apache.log4j.PatternLayout">
            <!-- The default pattern: Date Priority [Category] Message\n -->
            <param name="ConversionPattern" value="%d %-5p [%c] %m%n" />
        </layout>
    </appender>


    <!-- 
    <logger name="com.mycompany">
        <level value="debug" />
        <appender-ref ref="DEBUG_LOG" />
        <appender-ref ref="MAIN_LOG" />
    </logger>

    <logger name="com.othercompany">
        <level value="debug" />
        <appender-ref ref="DEBUG_LOG" />
        <appender-ref ref="MAIN_LOG" />
    </logger>
     -->

    <logger name="org">
        <appender-ref ref="MAIN_LOG" />
        <appender-ref ref="DEBUG_LOG" />
    </logger>


    <root>
    </root>

</log4j:configuration>




-Jim

----- Original Message ----
From: Mikael Ståldal <[EMAIL PROTECTED]>
To: log4j-user@logging.apache.org
Sent: Thursday, February 21, 2008 7:00:36 AM
Subject: Different levels to different appenders


I 
have 
two 
appenders, 
MAIN_LOG 
and 
DEBUG_LOG. 
I 
have 
the 
loggers 
set 
up 
to 
match 
Java 
class 
hierarchy 
as 
recommended. 
I 
have 
two 
interesting 
codebases, 
"com.mycompany" 
and 
"com.othercompany".

I 
want 
to 
send 
DEBUG 
and 
higher 
from 
"com.mycompany" 
and 
WARN 
and 
higher 
from 
"com.othercompany" 
to 
MAIN_LOG. 
And 
I 
want 
to 
send 
DEBUG 
and 
higher 
from 
"com.mycompany" 
and 
DEBUG 
and 
higher 
from 
"com.othercompany" 
to 
DEBUG_LOG.

Finally 
I 
want 
to 
handle 
stuff 
outside 
"com.mycompany" 
or 
"com.othercompany" 
(such 
as 
"org.thirdparty") 
by 
sending 
ERROR 
and 
higher 
to 
MAIN_LOG 
and 
INFO 
and 
higher 
to 
DEBUG_LOG.

How 
do 
I 
accomplish 
that?


---------------------------------------------------------------------
To 
unsubscribe, 
e-mail: 
[EMAIL PROTECTED]
For 
additional 
commands, 
e-mail: 
[EMAIL PROTECTED]







      
____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs

Reply via email to