log4j的是在

log4j属性创建日志,manual.log,manual.log.1所以如下,log4j的是在

#Application Logger 

log4j.rootLogger=DEBUG,file

#log4j.rootLogger=DEBUG,file,console

log4j.appender.file=org.apache.log4j.RollingFileAppender

log4j.appender.file.File=../common/logs/api/log4j-app.log

log4j.appender.file.maxFileSize=6MB

log4j.appender.file.maxBackupIndex=5

log4j.appender.file.layout=org.apache.log4j.PatternLayout

#log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c<span><span>{1}</span></span>:%L - %m%n

log4j.appender.file.layout.ConversionPattern=%d{ISO8601} %5p : %L -- %m%n

log4j.appender.file.Append=false

#Manual WebLogs

log4j.logger.webLogger=INFO, web

log4j.appender.web=org.apache.log4j.RollingFileAppender

log4j.appender.web.maxFileSize=900KB

log4j.appender.web.maxBackupIndex=6

log4j.appender.web.layout=org.apache.log4j.PatternLayout

#log4j.appender.web.layout.ConversionPattern=%d{ISO8601} %5p %F <Method>%M : %L -- %m%n

log4j.appender.web.layout.ConversionPattern=%d{ISO8601} %5p : %L -- %m%n

log4j.appender.web.File=../common/logs/web/manual.log

log4j.appender.web.Append=false

#Manual ApiLogs

log4j.logger.apiLogger=INFO, api ,console

log4j.appender.api=org.apache.log4j.RollingFileAppender

log4j.appender.api.maxFileSize=900KB

log4j.appender.api.maxBackupIndex=6

log4j.appender.api.layout=org.apache.log4j.PatternLayout

#log4j.appender.api.layout.ConversionPattern=%d{ISO8601} %5p %F <Method>%M : %L -- %m%n

log4j.appender.api.layout.ConversionPattern=%d{ISO8601} %5p : %L -- %m%n

log4j.appender.api.File=../common/logs/api/manual.log

log4j.appender.api.Append=false

#Manual ApiSecurityLogs

log4j.logger.apiSecurityLogger=INFO, apiSecurity

log4j.appender.apiSecurity=org.apache.log4j.RollingFileAppender

log4j.appender.apiSecurity.maxFileSize=900KB

log4j.appender.apiSecurity.maxBackupIndex=6

log4j.appender.apiSecurity.layout=org.apache.log4j.PatternLayout

#log4j.appender.apiSecurity.layout.ConversionPattern=%d{ISO8601} %5p %F <Method>%M : %L -- %m%n

log4j.appender.apiSecurity.layout.ConversionPattern=%d{ISO8601} : %L -- %m%n

log4j.appender.apiSecurity.File=../common/logs/apiSecurity/manualSecurity.log

log4j.appender.apiSecurity.Append=false

# Appender which writes to console

log4j.appender.console=org.apache.log4j.ConsoleAppender

log4j.appender.console.Target=System.out

log4j.appender.console.layout=org.apache.log4j.PatternLayout

log4j.appender.console.layout.ConversionPattern=%d{dd/MM/yyyy HH:mm:ss} %c %m%n

我们正在使用上述log4j.properties创建网络日志和API日志。

网络相关日志去web/manual.log。 api相关日志转到api/manual.log。 API安全相关的日志转到apiSecurity/manualSecurity.log

的API manual.loglog4j-app.log文件创建为 manual.log, manual.log.1, manual.log.2 ...等, log4j-app.log, log4j-app.log.1, log4j-app.log.2 ......等等。

我想要一个文件中的所有日志细节为manual.loglog4j-app.log,请让我知道如何获取它?

回答:

Appenders类型需要从RollingFileAppender更改为FileAppender。 所以对它进行改变后,你的log4j.properties看起来像:

#Application Logger 

log4j.rootLogger=DEBUG,file

#log4j.rootLogger=DEBUG,file,console

log4j.appender.file=org.apache.log4j.FileAppender

log4j.appender.file.File=log4j-app.log

#log4j.appender.file.maxFileSize=6MB

#log4j.appender.file.maxBackupIndex=5

log4j.appender.file.layout=org.apache.log4j.PatternLayout

#log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c<span><span>{1}</span></span>:%L - %m%n

log4j.appender.file.layout.ConversionPattern=%d{ISO8601} %5p : %L -- %m%n

log4j.appender.file.Append=false

#Manual WebLogs

log4j.logger.webLogger=INFO, web

log4j.appender.web=org.apache.log4j.FileAppender

#log4j.appender.web.maxFileSize=900KB

#log4j.appender.web.maxBackupIndex=6

log4j.appender.web.layout=org.apache.log4j.PatternLayout

#log4j.appender.web.layout.ConversionPattern=%d{ISO8601} %5p %F <Method>%M : %L -- %m%n

log4j.appender.web.layout.ConversionPattern=%d{ISO8601} %5p : %L -- %m%n

log4j.appender.web.File=../common/logs/web/manual.log

log4j.appender.web.Append=false

#Manual ApiLogs

log4j.logger.apiLogger=INFO, api ,console

log4j.appender.api=org.apache.log4j.FileAppender

#log4j.appender.api.maxFileSize=900KB

#log4j.appender.api.maxBackupIndex=6

log4j.appender.api.layout=org.apache.log4j.PatternLayout

#log4j.appender.api.layout.ConversionPattern=%d{ISO8601} %5p %F <Method>%M : %L -- %m%n

log4j.appender.api.layout.ConversionPattern=%d{ISO8601} %5p : %L -- %m%n

log4j.appender.api.File=manual.log

log4j.appender.api.Append=false

#Manual ApiSecurityLogs

log4j.logger.apiSecurityLogger=INFO, apiSecurity

log4j.appender.apiSecurity=org.apache.log4j.RollingFileAppender

log4j.appender.apiSecurity.maxFileSize=900KB

log4j.appender.apiSecurity.maxBackupIndex=6

log4j.appender.apiSecurity.layout=org.apache.log4j.PatternLayout

#log4j.appender.apiSecurity.layout.ConversionPattern=%d{ISO8601} %5p %F <Method>%M : %L -- %m%n

log4j.appender.apiSecurity.layout.ConversionPattern=%d{ISO8601} : %L -- %m%n

log4j.appender.apiSecurity.File=../common/logs/apiSecurity/manualSecurity.log

log4j.appender.apiSecurity.Append=false

# Appender which writes to console

log4j.appender.console=org.apache.log4j.ConsoleAppender

log4j.appender.console.Target=System.out

log4j.appender.console.layout=org.apache.log4j.PatternLayout

log4j.appender.console.layout.ConversionPattern=%d{dd/MM/yyyy HH:mm:ss} %c %m%n

以上是 log4j的是在 的全部内容, 来源链接: utcz.com/qa/261094.html

回到顶部