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

 

Reply via email to