Hi folks -

I'm frustrated in trying to control the run-time configuration of Log4j in
my standalone application.  I have log4j-1.2.13.jar in my classpath.  I
have a log4j.properties file configured as shown below.  It seems that I
have no idea where to place the property file in my classpath for log4j to
find/use it.    Right now, it seems that no matter where I put it the
logging level is always on INFO,   In fact, it's on INFO even if I
completely delete the log4j.properties file from the project!

Please help me figure out how to properly control the logging level using
log4j.properties file - like the one below...  I would liket to set the
package level control to DEBUG or INFO, etc.   Where do I put it, and how
do I instruct logging framework to find and use this config file.

log4j.properties file - currently located in /target/classes directory:
-------------------------------------------------------------------------------------------------------
### direct log messages to stdout ###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L -
%m%n

### set log levels - for more verbose logging change 'info' to 'debug' ###

log4j.rootLogger=debug

###  debug your specific package or classes with the following example
log4j.logger.com.ibm.cods.batch.common.processor.email=debug
-------------------------------------------------------------------------------------------------------

My program has the following statements in it:

-------------------------------------------------------------------------------------------------------
package com.ibm.cods.batch.common.processor.email;

import junit.framework.TestCase;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Logger;


public class Log4J_TestHarness extends TestCase {

    private static org.apache.log4j.Logger log =
Logger.getLogger(Log4J_TestHarness.class);

    protected void setUp() throws Exception {
        super.setUp();
    }

    public void testLog4J_Configuration()  {
        log.info(">>>>>>>>>>>  starting new test case:
testLog4J_Configuration()");
        log.debug("hello from DEBUG!");
        log.info("<<<<<<<<<<<<  end test case:
testLog4J_Configuration()");
    }

}

-------------------------------------------------------------------------------------------------------


Reply via email to