Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Log4j not printing to file or stdout

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 !

like image 937
TomSelleck Avatar asked Apr 21 '13 14:04

TomSelleck


1 Answers

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

like image 119
anazimok Avatar answered Oct 07 '22 00:10

anazimok