crankshaft
crankshaft

Reputation: 2677

Java library is overriding log4j.properties

I have a log4j.properties file:

    # Root logger option
    log4j.rootLogger=WARN, stdout, file

    # Redirect log messages to console
    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

    # Redirect log messages to a log file, support file rolling.
    log4j.appender.file.append=false
    log4j.appender.file=org.apache.log4j.RollingFileAppender
    log4j.appender.file.File=log/pure-pentaho.log
    log4j.appender.file.MaxFileSize=5MB
    log4j.appender.file.MaxBackupIndex=10
    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

This works fine until I include the bsf-2.4.0.jar library and then all of my logging stops.

So I am guessing that this library is somehow overriding my logger, how can I get it to resume logging again ?

Edit

OK, as suggested, I added the path as a command line option and it works:

java -Dlog4j.configuration=file:./run/log4j.properties -cp ./lib/*:./run myApp &

Upvotes: 0

Views: 1769

Answers (1)

Rocherlee
Rocherlee

Reputation: 2791

It seems there are multiple log4j.properties files in the classpath, and log4j did not pick up yours.

You can rename your file, add a JVM argument to specify your desired file.

-Dlog4j.configuration=/home/user/mylog4j.properties

To set JVM Arguments on Eclipse, right click on the project > Run as > Run Configurations... > Arguments > VM Arguments

Upvotes: 1

Related Questions