开发者

Log4j referring to external properties file in class path

I have a log4j.properties file

    log4j.appender.Big开发者_如何学JAVABrotherLog=org.apache.log4j.RollingFileAppender
    log4j.appender.BigBrotherLog.File=${userprofile.broker.bigbrother.log4j.file.path}
    log4j.appender.BigBrotherLog.MaxFileSize=100MB
    log4j.appender.BigBrotherLog.MaxBackupIndex=10
    log4j.appender.BigBrotherLog.layout=org.apache.log4j.PatternLayout
    log4j.appender.BigBrotherLog.layout.ConversionPattern=%d{yy/MM/dd} %d{HH:mm:ss} ALARM CRITICAL SITA ESB (SOAESB) [%-t] (%F:%L) %-5p %-c{1} %x- %m%n
    log4j.appender.BigBrotherLog.Threshold=FATAL

where I'm passing ${userprofile.broker.bigbrother.log4j.file.path} from a external properties file. But I want to have put this external properties file in the class path. How can I make it work? Thanks.


When you invoke the java command, pass in the system property -Dlog4j.configuration=file:[path-to-your-external-file]. The important part is the file:, otherwise log4j will only attempt to load from the class path and system resources.

You can also use -Dlog4j.debug=true to see where log4j has attempted to source it's configuration file from.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜