I just downloaded Log4j and am trying to test it out. I copied a sample properties file to print to stdout and a file from here but it does neither.
Here is my code:
public class ClientTest {
//static CanvasFrame canvas = new CanvasFrame("Web Cam");
static Logger logger = Logger.getLogger(ClientTest.class);
public static void main(String [] args) {
BasicConfigurator.configure();
logger.debug("HERPADERP");
Client bob = new Client("localhost", 6789);
bob.startRunning();
}
}
And log4j.properties :
# Root logger option
log4j.rootLogger=INFO, file, stdout
# Direct log messages to a log file
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=Log/log.log
log4j.appender.file.MaxFileSize=1MB
log4j.appender.file.MaxBackupIndex=1
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
# 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{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
The log.log file is created but nothing is ever written to it...
Can anybody spot where I am going wrong?? Thanks !
Your logger's level is set to INFO. You are using debug statements. Change
log4j.rootLogger=INFO, file, stdout
to
log4j.rootLogger=DEBUG, file, stdout
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With