标签:log4j
使用slf4j作为日志系统时,由于slf4j只是一个接口,它需要一个具体实现来执行。
具体参考http://blog.csdn.net/jediael_lu/article/details/43854571
由于slf4j统一了API接口,因此,若log4j实现来日志输出,则只需要设置配置文件的内容即可,以下是nutch中默认的log4j.properties。
# Define some default values that can be overridden by system properties hadoop.log.dir=. hadoop.log.file=hadoop.log # RootLogger - DailyRollingFileAppender log4j.rootLogger=INFO,DRFA # Logging Threshold log4j.threshold=ALL #special logging requirements for some commandline tools log4j.logger.org.apache.nutch.crawl.Crawl=INFO,cmdstdout log4j.logger.org.apache.nutch.crawl.InjectorJob=INFO,cmdstdout log4j.logger.org.apache.nutch.host.HostInjectorJob=INFO,cmdstdout log4j.logger.org.apache.nutch.crawl.GeneratorJob=INFO,cmdstdout log4j.logger.org.apache.nutch.crawl.DbUpdaterJob=INFO,cmdstdout log4j.logger.org.apache.nutch.host.HostDbUpdateJob=INFO,cmdstdout log4j.logger.org.apache.nutch.fetcher.FetcherJob=INFO,cmdstdout log4j.logger.org.apache.nutch.parse.ParserJob=INFO,cmdstdout log4j.logger.org.apache.nutch.indexer.IndexingJob=INFO,cmdstdout log4j.logger.org.apache.nutch.indexer.DeleteDuplicates=INFO,cmdstdout log4j.logger.org.apache.nutch.indexer.CleaningJob=INFO,cmdstdout log4j.logger.org.apache.nutch.crawl.WebTableReader=INFO,cmdstdout log4j.logger.org.apache.nutch.host.HostDbReader=INFO,cmdstdout log4j.logger.org.apache.nutch.parse.ParserChecker=INFO,cmdstdout log4j.logger.org.apache.nutch.indexer.IndexingFiltersChecker=INFO,cmdstdout log4j.logger.org.apache.nutch.plugin.PluginRepository=WARN log4j.logger.org.apache.nutch.api.NutchServer=INFO,cmdstdout log4j.logger.org.apache.nutch=INFO log4j.logger.org.apache.hadoop=WARN log4j.logger.org.apache.zookeeper=WARN log4j.logger.org.apache.gora=WARN # # Daily Rolling File Appender # log4j.appender.DRFA=org.apache.log4j.DailyRollingFileAppender log4j.appender.DRFA.File=${hadoop.log.dir}/${hadoop.log.file} # Rollver at midnight log4j.appender.DRFA.DatePattern=.yyyy-MM-dd # 30-day backup #log4j.appender.DRFA.MaxBackupIndex=30 log4j.appender.DRFA.layout=org.apache.log4j.PatternLayout # Pattern format: Date LogLevel LoggerName LogMessage log4j.appender.DRFA.layout.ConversionPattern=%d{ISO8601} %-5p %c{2} - %m%n # Debugging Pattern format: Date LogLevel LoggerName (FileName:MethodName:LineNo) LogMessage #log4j.appender.DRFA.layout.ConversionPattern=%d{ISO8601} %-5p %c{2} (%F:%M(%L)) - %m%n # # stdout # Add *stdout* to rootlogger above if you want to use this # log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%d{ISO8601} %-5p %c{2} (%F:%M(%L)) - %m%n # # plain layout used for commandline tools to output to console # log4j.appender.cmdstdout=org.apache.log4j.ConsoleAppender log4j.appender.cmdstdout.layout=org.apache.log4j.PatternLayout log4j.appender.cmdstdout.layout.ConversionPattern=%m%n # # Rolling File Appender # #log4j.appender.RFA=org.apache.log4j.RollingFileAppender #log4j.appender.RFA.File=${hadoop.log.dir}/${hadoop.log.file} # Logfile size and and 30-day backups #log4j.appender.RFA.MaxFileSize=1MB #log4j.appender.RFA.MaxBackupIndex=30 #log4j.appender.RFA.layout=org.apache.log4j.PatternLayout #log4j.appender.RFA.layout.ConversionPattern=%d{ISO8601} %-5p %c{2} - %m%n #log4j.appender.RFA.layout.ConversionPattern=%d{ISO8601} %-5p %c{2} (%F:%M(%L)) - %m%n
以下是配置文件项的说明:转载http://www.cnblogs.com/alipayhutu/archive/2012/06/21/2558249.html
log4j.rootLogger=日志级别,appender1, appender2, ….
log4j.appender.appender1=org.apache.log4j.日志输出到哪儿
log4j.appender.appender1.File=文件目录及文件
${user.home}/logs/...
log4j.appender.appender1.MaxFileSize=最大文件大小
log4j.appender.appender1.MaxBackupIndex=备份文件个数
log4j.appender.ServerDailyRollingFile.DatePattern=日志后缀格式
log4j.appender.appender1.layout=org.apache.log4j.日志布局格式
log4j.appender.appender1.layout.ConversionPattern=日志输出格式
log4j.appender.ServerDailyRollingFile.Append=true
总结一下:
标签:log4j
原文地址:http://blog.csdn.net/jediael_lu/article/details/43865571