configure log4j to log to custom file at runtime

后端 未结 4 446
逝去的感伤
逝去的感伤 2020-11-28 02:40

Can anyone please guide me as to how I can configure log4j to log to a specific file that I specify at run-time.The name and path of the log file are generated at run-time a

4条回答
  •  渐次进展
    2020-11-28 02:56

    Can be also done by this properties define in log4j.properties file

    log4j.appender.logfile=org.apache.log4j.RollingFileAppender
    log4j.appender.logfile.maxFileSize=5000KB
    log4j.appender.logfile.maxBackupIndex=5
    log4j.appender.logfile.File=/WebSphere/AppServer/profiles/Custom01/error.log
    log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
    log4j.appender.logfile.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %5p [%t] %C %M %c{1}:%L - %m%n
    

提交回复
热议问题