Tested and confirmed, thanks Curt! This was exactly what I was looking for (and a single prop file is fine).
-D > -----Original Message----- > From: Curt Arnold [mailto:[EMAIL PROTECTED] > Sent: Tuesday, April 12, 2005 11:39 AM > To: Log4J Users List > Subject: Re: Multiple loggers, same application? > > You may need to tweak this for your own requirements. Almost > all of the log4j examples demonstrate using classnames for > logger names, however this is a case where you would want to > use a slightly different pattern. Hopefully, you have read > http://logging.apache.org/log4j/docs/manual.html and > understand the concept of a logger hierarchy. > > To address your issue, you would want to use logger names > like "security" or "security." + classname, "audit" or > "audit." + classname, etc. You'd add the class name if you > wanted to be able to control the security messages based on the class. > > class MyClass { > private static Logger securityLogger = > Logger::getLogger("security." + MyClass.class.getName()); > private static Logger auditLogger = > Logger::getLogger("audit." + MyClass.class.getName()); > // > // standard diagnostic logger > private static Logger logger = Logger::getLogger(MyClass.class); > .. > .. > void doSomething() { > securityLogger.info("attempt to do something"); > } > } > > > In your configuration file, you would configure the root > logger to handle general diagnostic logs (that is, every > logger that doesn't start with "security" or "audit") and > configure "security" and "audit" > as appropriate. You may (or may not) want to set additivity > to false so that something logged to > "security.com.example.foobar" doesn't end up in the general > diagnostic log. > > log4j.rootLogger=INFO, A1 > log4j.appender.A1=org.apache.log4j.ConsoleAppender > log4j.appender.A1.layout=org.apache.log4j.PatternLayout > > # Print the date in ISO 8601 format > log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c - %m%n > > log4j.logger.security=WARN,A2 > log4j.additivity.security=false > > log4j.logger.audit=DEBUG,A3 > log4j.additivity.audit=false > > # > # define appenders A2 and A3 as appropriate > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
