I suggest that you create 2 loggers per class.
Logger logger = Logger.getLogger(getClass());
Logger loggerSpecial = Logger.getLogger("special." + getClass().getName());

log4j.rootLogger=ERROR
log4j.category.org = A1
log4j.category.special = SPECIAL_APPENDER

(I am not positive if I have the properties entries correct.)

On 9/14/06, Bryce Nesbitt <[EMAIL PROTECTED]> wrote:
I wish to write a separate log of certain special and important
messages.  In perl, this might go:

    print NORMALLOG "foo";
    print NORMALLOG "fum"
    print SPECIALLOG "special message";

Can this be done with log4j?  This would be something looking roughly like:

    logger.info("fum");
    logger.debug("foo");
    logger.debug("loo");
    logger.info(SPECIAL_APPENDER,"foo");

I can't divide these messages based on the class that's printing them.
I somehow need to create a new and totally separate log file.  Is this
possible?

          -Bryce


PS1:  Why?  This is a poorman's mirroring system.  The idea is to dump a
certain special checkpoint messages to a remote syslog server for archiving.

PS1: the log4j.properties file is:

log4j.appender.A1 = org.apache.log4j.RollingFileAppender
log4j.appender.A1.file = /tmp/fooble.log
log4j.appender.A1.layout = org.apache.log4j.PatternLayout
log4j.appender.A1.layout.conversionPattern = %d %-5p %m - %c{2}%n
log4j.appender.A1.append = false

log4j.appender.SPECIAL_APPENDER=org.apache.log4j.net.SyslogAppender
log4j.appender.SPECIAL_APPENDER.SPECIAL_APPENDERHost=209.99.99.31
log4j.appender.SPECIAL_APPENDER.layout=org.apache.log4j.PatternLayout
log4j.appender.SPECIAL_APPENDER.layout.ConversionPattern=%p: %c - %m
log4j.appender.SPECIAL_APPENDER.Facility=SPECIAL_APPENDER

log4j.rootLogger=ERROR, A1
log4j.category.org.foo.fum = SPECIAL_APPENDER

This works fine, except org.foo.fum needs to continue to send regular
output to A1, without cluttering SPECIAL_APPENDER.


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




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

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

Reply via email to