Load a log4j properties file:
PropertyConfigurator.configure("log4j.properties");
then in the file define what you want.
File might look like this:
log4j.rootCategory=DEBUG, LoggingFile
# Console is set to be a ConsoleAppender.
log4j.appender.Console=org.apache.log4j.ConsoleAppender
# LoggingFile is set to be a FileAppender.
log4j.appender.LoggingFile=org.apache.log4j.FileAppender
log4j.appender.LoggingFile.File=c:/sdca/logs/sdca.log
# LoggingFile uses PatternLayout.
log4j.appender.LoggingFile.layout=org.apache.log4j.PatternLayout
log4j.appender.LoggingFile.layout.ConversionPattern=%-4d [%-12t] %-5p %c %x - %m%n
So to stop all DEBUG messages change the line
log4j.rootCategory=DEBUG, LoggingFile
to
log4j.rootCategory=WARN, LoggingFile
A quite amazing error for someone using log4j to log errors.
How can it not find the package org.apache.log4j
I've never used am XML File for log4j config sorry.
Strangely, after I posted I started to have some problems with trying to stop certain classes from sending lots of debug. Here is the final log4j.properties file I use
log4j.rootLogger= DEBUG, A1, A2
log4j.logger.org.apache.commons.httpclient = WARN, A1
log4j.logger.httpclient= WARN, A1
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%d [%t][%-5p][%c] %m%n
# file appender
log4j.appender.A2=org.apache.log4j.FileAppender
log4j.appender.A2.File=C:/SDCA/logs/sdca.log
log4j.appender.A2.Append=false
log4j.appender.A2.layout=org.apache.log4j.PatternLayout
log4j.appender.A2.layout.ConversionPattern=%d [%t][%-5p][%c] %m%n
This file sits in the same directory from which the program is run.
Just today I went through the same horrible ordeal.
A couple notes about the default JBoss log4j.xml file it seems to affect the logging somewhat, from my understanding you SHOULD do this:
The <root> category should have a priority added:
<root>
<priority value="WARN" />
<appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/>
</root>
That should set the default root category to only display WARNING messages. There's another category (name="org.jboss.resource.connectionmanager.JBossManagedConnectionPool") with priority set to TRACE. Change that to WARN or ERROR.
I set up my own server directory structure and left out the log4j.jar from the lib directory, so it hadn't been actually reading the XML file. Just something to watch out for.
Another thing I found was that the bin/run.jar has a log4j.properties file with rootCategory=DEBUG which generates the boot.log file. I un-jarred the file and set that to INFO, then re-jarred it... I couldn't get rid of all the DEBUG messages without doing so.