Attachment didn't work - so here's the file:
org.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.Log4jFactory
# Set root category priority to DEBUG and its appenders to stdout and R.
log4j.rootCategory=debug, stdout, R_commons
# Configure stdout appender - set layout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%d{dd MMM yyyy HH:mm:ss,SSS}] %5p [%t]
(%c) - %m%n
# commons.log Appender
log4j.appender.R_commons=org.apache.log4j.RollingFileAppender
log4j.appender.R_commons.File=log/commons.log
log4j.appender.R_commons.MaxFileSize=1024KB
log4j.appender.R_commons.MaxBackupIndex=1
log4j.appender.R_commons.layout=org.apache.log4j.PatternLayout
log4j.appender.R_commons.layout.ConversionPattern=[%d{dd MMM yyyy HH:mm:ss,SSS}] %5p
[%t] %c - %m%n
-----Original Message-----
From: Maher Martin
Sent: Monday, July 07, 2003 2:57 PM
To: Jakarta Commons Users List
Subject: RE: [Logging] Problem with Log4J configuration
Sorry,
I forgot to attach the properties file.
-----Original Message-----
From: Maher Martin
Sent: Monday, July 07, 2003 2:52 PM
To: Jakarta Commons Users List
Subject: [Logging] Problem with Log4J configuration
Hi,
I'm having problems configuring the Logging instance with my Logging Properties. I'm
using the following configuration mechanism:
1) I added the Log4J jar file to the classpath
2) I added the commons-logging.properties file to the classpath (see attached file)
(Note: the property org.apache.commons.logging.LogFactory on the first line instructs
the logger to use the Log4JFactory )
3) I attempt to use the logger using the following code:
Log _log = LogFactory.getLog(this.class.getName());
_log.debug("DEBUG");
_log.error("ERROR");
_log.fatal("FATAL");
_log.info("INFO");
_log.trace("TRACE");
_log.warn("WARN");
I expect the output to look like the following:
[07 Jul 2003 13:50:41,864] DEBUG [main] (com.webasto.commonstest.Test) - DEBUG
[07 Jul 2003 13:50:41,864] ERROR [main] (com.webasto.commonstest.Test) - ERROR
[07 Jul 2003 13:50:41,864] FATAL [main] (com.webasto.commonstest.Test) - FATAL
[07 Jul 2003 13:50:41,864] INFO [main] (com.webasto.commonstest.Test) - INFO
[07 Jul 2003 13:50:41,874] WARN [main] (com.webasto.commonstest.Test) - WARN
However I get the following output:
0 [main] ERROR commonstest.Test - ERROR
10 [main] FATAL commonstest.Test - FATAL
10 [main] INFO commonstest.Test - INFO
10 [main] WARN commonstest.Test - WARN
It seems from the output above that the properties are not being passed to Log4J.
However I checked that they are being loaded from the properties file using the
following code:
Log4jFactory fact = (Log4jFactory) LogFactory.getFactory();
String[] attributeNames = fact.getAttributeNames();
for (int i = 0; i < attributeNames.length; i++) {
String name = attributeNames[i];
String value = (String) fact.getAttribute(name);
System.out.println("CONFIG: Name:" + name + ", Value:" + value);
}
I checked the properties file directly with Log4J and the log messages were outputted
as expected.
I'm using commons-logging version 1.0.2 and Log4J version 1.2.8.
Thanks in advance,
Martin Maher
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]