java - log4j 里的日志如何通过shell 重定向?
巴扎黑
巴扎黑 2017-04-18 10:32:11
0
1
402

有个一个test.jar,里面用了log4j做日志输出。现在是输出到logs文件夹里

但是现在需要换成用一个shell来执行

java -jar test.jar $param1 $param2 > /newLogs/xxxx.log

如何配置才能将log4j的日志直接通过 > 重定向到xxxx.log中?

巴扎黑
巴扎黑

reply all(1)
Peter_Zhu

appender 使用 console will be output to the file.

Is this it?

log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.Threshold=INFO
log4j.appender.console.ImmediateFlush=true
log4j.appender.console.Target=System.out
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%n%-d{yyyy-MM-dd HH:mm:ss}%n[%p]-[Thread: %t]-[%C.%M()]: %m%n
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template