You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by chuanjiang lo <lo...@gmail.com> on 2006/12/02 07:36:38 UTC

Setting up log4j.xml

Hi all,

I would like to know how i can set up my log4j.xml, for e.g info level would
be printed onto the console where debug level would be log into a file.

These are the snippets of my log4j.xml

<appender name="info-appender" class="org.apache.log4j.ConsoleAppender">
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d{dd MMM yyyy HH:mm:ss}
[%t] %-5p %c - %m%n"/>
    </layout>
    </appender>

    <appender name="debug-appender" class="org.apache.log4j.FileAppender">
        <param name="file" value="debug.log"/>
        <layout class="org.apache.log4j.SimpleLayout"/>
    </appender>

    <root>
        <priority value="debug"/>
        <appender-ref ref="debug-appender"/>
    </root>

I'm not very sure how i can set up the environment, probably need some
advice from experienced users.

Appreciate any help

Re: Setting up log4j.xml

Posted by chuanjiang lo <lo...@gmail.com>.
i'm having this config..
i would like to print out error and fatal msgs in the Main class of
loggingexample package, how come it is still printing debug level and above
msgs?

appreciate any help

    <appender name="A1" class="org.apache.log4j.ConsoleAppender">
        <layout class="org.apache.log4j.PatternLayout">
            <!-- Print the date in ISO 8601 format -->
            <param name="ConversionPattern" value="%d [%t] %-5p %c - %m%n"/>

        </layout>
    </appender>

   <logger name="loggingexample.Main">
        <level value="error"/>
    </logger>

    <root>
        <level value="debug"/>
        <appender-ref ref="A1" />
    </root>

Re: Setting up log4j.xml

Posted by chuanjiang lo <lo...@gmail.com>.
On 12/3/06, James Stauffer <st...@gmail.com> wrote:
>
> Set a threshold on info appender and send root logs to both appenders.



i found this great example on the net

http://wiki.apache.org/logging-log4j/LogByLevel

appreciate your help!

Re: Setting up log4j.xml

Posted by James Stauffer <st...@gmail.com>.
Set a threshold on info appender and send root logs to both appenders.

On 12/2/06, chuanjiang lo <lo...@gmail.com> wrote:
> Hi all,
>
> I would like to know how i can set up my log4j.xml, for e.g info level would
> be printed onto the console where debug level would be log into a file.
>
> These are the snippets of my log4j.xml
>
> <appender name="info-appender" class="org.apache.log4j.ConsoleAppender">
>         <layout class="org.apache.log4j.PatternLayout">
>             <param name="ConversionPattern" value="%d{dd MMM yyyy HH:mm:ss}
> [%t] %-5p %c - %m%n"/>
>     </layout>
>     </appender>
>
>     <appender name="debug-appender" class="org.apache.log4j.FileAppender">
>         <param name="file" value="debug.log"/>
>         <layout class="org.apache.log4j.SimpleLayout"/>
>     </appender>
>
>     <root>
>         <priority value="debug"/>
>         <appender-ref ref="debug-appender"/>
>     </root>
>
> I'm not very sure how i can set up the environment, probably need some
> advice from experienced users.
>
> Appreciate any help
>
>


-- 
James Stauffer        http://www.geocities.com/stauffer_james/
Are you good? Take the test at http://www.livingwaters.com/good/

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