Get live Log4J messages

前端 未结 3 474
南笙
南笙 2021-01-23 05:15

How do I get what is being written by log4j in central class which monitors all log4j logs in the application?

Thanks

Edit: I wish I would not have to read it fr

3条回答
  •  隐瞒了意图╮
    2021-01-23 05:40

    You can implement your own Appender and copy all logs on it using the normal config:

    log4j.rootLogger=WARN, file, other
    
    log4j.appender.file=org.apache.log4j.RollingFileAppender
    log4j.appender.file.File=${catalina.home}/logs/log.log
    log4j.appender.file.MaxFileSize=10MB
    log4j.appender.file.MaxBackupIndex=10
    log4j.appender.file.layout=org.apache.log4j.PatternLayout
    log4j.appender.file.layout.ConversionPattern=%d{ISO8601} %p %t %c - %m%n
    
    log4j.appender.other=class.path.of.your.Appender
    

提交回复
热议问题