My advice:  Don't split your logs into a Debug and Info log files.  Not that log4j can't do that (see more below) but seriously consider that both the debug and info logs are even more useful when you have the context of them together.  So my advice is to have one file appender, attached to all loggers you wish to capture logs from, and set your loggers to DEBUG.  this will give you both Debug and Info (and other levels) in the one file making understanding what is going on much simpler, since you can see them in sequence.


However... if you must... and you really want to.. Then create 2 file appenders, and set the _Appenders_ to have a Filter that only accepts the Level you are interested in (you might need to write a simple filter class for this), Debug or Info (for which ever file you wanted), then set your loggers to the lowest threshold you want to capture (debug) and attach BOTH appenders to all the loggers.  This way a logger emits a DEBUG log event, which goes to both appenders, but each appender decides whether to append it to the file, because of the Filter.

cheers,

Paul


On 17/01/2007, at 1:13 PM, Lisa wrote:


James Stauffer <stauffer.james <at> gmail.com> writes:


1. <category> -> <logger>
2. Remove class attribute from category/logger.
3. Define a <root> node at the bottom.


Thanks!  but I still have a few problems.  #3 <root> node was not required.  The
appender stayed the same.  the category (changed to logger) now looks like this:
(note priority is no longer an acceptable tag - changed to level)

    <!-- myfaces-impl -->
    <logger
            name="org.apache.myfaces"
            additivity="false">
        <level value="debug"/>
        <appender-ref ref="JSF.INFO.LOG"/>
    </logger>

But now I want a debug log file with debug messages and above and an info file
with info and above on the same package.  It appears to me that the
name="<package>" is the limiting param but also functions as an id for the
<logger> tag so log4j is complaining. 

    <!-- presence-tech (debug) -->
    <logger
            name="com.presence"
            additivity="false">
        <level value="debug"/>
        <appender-ref ref="PT.DEBUG.LOG"/>
    </logger>

    <!-- presence-tech (info) -->
    <logger
            name="com.presence"
            additivity="false">
        <level value="info"/>
        <appender-ref ref="PT.INFO.LOG"/>
    </logger>

How do I create two loggers that limit to com.presence (one logger for 
debug and one for info)?

Log4J startup gives the following error message:
  log4j:WARN Attribute value "com.presence" of type ID must be unique within 
the document.

So how do you have two loggers that limit to the same package but different
levels (debug,info)?


Thanks

Lisa






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


Paul Smith
Engineering Manager

Aconex
The easy way to save time and money on your project

696 Bourke Street, Melbourne,
VIC 3000, Australia
Tel: +61 3 9240 0200  Fax: +61 3 9240 0299
Email: psmith@aconex.com  www.aconex.com
 

This email and any attachments are intended solely for the addressee. The contents may be privileged, confidential and/or subject to copyright or other applicable law. No confidentiality or privilege is lost by an erroneous transmission. If you have received this e-mail in error, please let us know by reply e-mail and delete or destroy this mail and all copies. If you are not the intended recipient of this message you must not disseminate, copy or take any action in reliance on it. The sender takes no responsibility for the effect of this message upon the recipient's computer system.