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 Asaf Lahav <as...@primagrid.com> on 2006/03/12 21:50:44 UTC
simple log4j question
Hi,
I am trying to use a log4j.properties configuration file and define several
categories.
Code I'm using(found it on a sample code):
//this of course has to happen once in the loader
class
PropertyConfigurator.configure("log4j.properties");
// this is what I want to do. extract a logger which
gets a configuration set from the log4j.properties file
Logger pgLogger =
LogManager.getLogger("www.pg.com");
Logger pgLogger2 =
LogManager.getLogger("www.pg.com2");
pgLogger.info("my message");
pgLogger2.info("my second message");
This is the properties file content I'm using:
log4j.rootLogger=info, stdout
# console
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
# Pattern to output the caller's file name and line number.
log4j.appender.stdout.layout.ConversionPattern=%d %5p [%t] - %m%n
# file
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=c:/logs/err.log
log4j.appender.R.MaxFileSize=100KB
# Keep one backup file
log4j.appender.R.MaxBackupIndex=5
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d [%t] %c (%F\:%L) - %m%n
How am I supposed to configure the properties file in order define those two
(or more) loggers?
Asaf Lahav
VP R&D, Prima Grid LTD.
Cellular: 972-54-4717955
Phone: 972-3-6540255
Fax: 972-3-6540254
Re: simple log4j question
Posted by Curt Arnold <ca...@apache.org>.
On Mar 12, 2006, at 2:50 PM, Asaf Lahav wrote:
> How am I supposed to configure the properties file in order define
> those two (or more) loggers?
Applications typically use many more loggers than those mentioned in
the configuration file. You do not need to mention every logger in
use in the application in the configuration file, you only need to
refer to those loggers where their is a change in the rules used to
process the message. Your configuration appears to be totally
adequate as long as you want to route all messages of info level or
higher on any logger to the console.
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org