log4j 1.0 、2.0 | logback
log4j 1.0 、2.0 | logback
yizhichao 发表于8个月前
log4j 1.0 、2.0 | logback
  • 发表于 8个月前
  • 阅读 15
  • 收藏 0
  • 点赞 0
  • 评论 0

腾讯云 新注册用户 域名抢购1元起>>>   

log4j1.0 配置文件 

# Global logging configuration
#log4j.rootLogger=info,dailyRollingFile,stdout
#log4j.rootLogger=debug,stdout,dailyRollingFile
#log4j.appender.stdout=org.apache.log4j.ConsoleAppender
#log4j.appender.stdout.Target=System.out
#log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
#log4j.appender.stdout.layout.ConversionPattern=[%d][%-5p][%l][%t] - %m - %n

# The five logging levels used by Log are (in order):
#
#   1. DEBUG (the least serious)
#   2. INFO
#   3. WARN
#   4. ERROR
#   5. FATAL (the most serious)

log4j.rootLogger=DEBUG,stdout,B_ADS

log4j.logger.org.apache.axis=INFO

log4j.logger.com.allcam.ryb.ads.core.modules=DEBUG,B_ADS
log4j.additivity.com.allcam.ryb.ads.core.modules=false
log4j.appender.B_ADS=org.apache.log4j.RollingFileAppender
log4j.appender.B_ADS.MaxFileSize=200MB
log4j.appender.B_ADS.MaxBackupIndex=50
log4j.appender.B_ADS.File=${catalina.base}/logs/allcam/b_ads_modules.log
log4j.appender.B_ADS.layout=org.apache.log4j.PatternLayout
log4j.appender.B_ADS.layout.ConversionPattern=%d{yyyy-MM-dd HH\:mm\:ss,SSS} %t%r%5p %c\:%L - %m%n

log4j.logger.com.allcam.ryb.ads.core.common=DEBUG,common
log4j.additivity.com.allcam.ryb.ads.core.common=false
log4j.appender.common=org.apache.log4j.RollingFileAppender
log4j.appender.common.MaxFileSize=200MB
log4j.appender.common.MaxBackupIndex=50
log4j.appender.common.File=${catalina.base}/logs/allcam/b_ads_common.log
log4j.appender.common.layout=org.apache.log4j.PatternLayout
log4j.appender.common.layout.ConversionPattern=%d{yyyy-MM-dd HH\:mm\:ss,SSS} %t%r%5p %c\:%L - %m%n

log4j.logger.com.allcam.ryb.ads.core.timerjob=ERROR,timerjob
log4j.additivity.com.allcam.ryb.ads.core.timerjob=false
log4j.appender.timerjob=org.apache.log4j.RollingFileAppender
log4j.appender.timerjob.MaxFileSize=200MB
log4j.appender.timerjob.MaxBackupIndex=50
log4j.appender.timerjob.File=${catalina.base}/logs/allcam/b_ads_timerjob.log
log4j.appender.timerjob.layout=org.apache.log4j.PatternLayout
log4j.appender.timerjob.layout.ConversionPattern=%d{yyyy-MM-dd HH\:mm\:ss,SSS} %t%r%5p %c\:%L - %m%n


#log4j.appender.dailyRollingFile=org.apache.log4j.DailyRollingFileAppender
#log4j.appender.dailyRollingFile.File=${catalina.base}/logs/allcam/B_ADS.log
#log4j.appender.dailyRollingFile.DatePattern='.'yyyy-MM-dd
#log4j.appender.dailyRollingFile.layout=org.apache.log4j.PatternLayout
#log4j.appender.dailyRollingFile.layout.ConversionPattern=[%d][%-5p][%l][%t] - %m - %n
#log4j.appender.dailyRollingFile.MaxBackupIndex=7
#log4j.appender.dailyRollingFile.MaxFileSize=10MB---only for RollingFileAppender use

log4j.logger.com.ibatis=ERROR   
log4j.logger.com.ibatis.common.jdbc.SimpleDataSource=ERROR   
log4j.logger.com.ibatis.common.jdbc.ScriptRunner=ERROR   
log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=ERROR
   
log4j.logger.org.apache=INFO  
log4j.logger.java.sql.Connection=DEBUG   
log4j.logger.java.sql.Statement=DEBUG   
log4j.logger.java.sql.PreparedStatement=DEBUG   
log4j.logger.java.sql.ResultSet=INFO

log4j.logger.org.springframework=ERROR
log4j.logger.org.apache.struts2=ERROR
log4j.logger.org.apache.commons=ERROR
log4j.logger.com.mchange=ERROR
log4j.logger.org.quartz=ERROR
log4j.logger.com.opensymphony.xwork2=ERROR
log4j.logger.com.opensymphony.xwork2.ActionSupport=ERROR

log4j2.0 配置文件 

<?xml version="1.0" encoding="UTF-8"?>
<!-- status=debug 可以查看log4j的装配过程 -->
<configuration status="off" monitorInterval="1800">
	<properties>
		<property name="LOG_HOME">/home/smartshop/apache-tomcat-8.0.32/logs/allcam</property>
		<!-- 日志备份目录 -->
		<property name="BACKUP_HOME">{LOG_HOME}/backup</property>
		<property name="STAT_NAME">stat</property>
		<property name="SERVER_NAME">global</property>
	</properties>
	<appenders>
	  	<!-- <File name="ApplicationLog" fileName="${logging.path}/${logging.file}"/> -->
	  	<!-- <File name="ApplicationLog" fileName="${web:rootDir}/app.log"/> -->
		<!-- 定义控制台输出 -->
		<Console name="Console" target="SYSTEM_OUT" follow="true">
			<PatternLayout
				pattern="%date{yyyy-MM-dd HH:mm:ss.SSS} %level [%thread][%file:%line] - %msg%n" />
		</Console>
		<!-- 程序员调试日志 -->
		<RollingRandomAccessFile name="DevLog"
			fileName="${LOG_HOME}/${SERVER_NAME}" filePattern="${LOG_HOME}/${SERVER_NAME}.%d{yyyy-MM-dd-HH}.log">
			<PatternLayout
				pattern="%date{yyyy-MM-dd HH:mm:ss.SSS} %level [%thread][%file:%line] - %msg%n" />
			<Policies>
				<TimeBasedTriggeringPolicy interval="1"
					modulate="true" />
			</Policies>
		</RollingRandomAccessFile>
		<!-- 产品数据分析日志 -->
		<RollingRandomAccessFile name="ProductLog"
			fileName="${LOG_HOME}/${SERVER_NAME}_${STAT_NAME}"
			filePattern="${LOG_HOME}/${SERVER_NAME}_${STAT_NAME}.%d{yyyy-MM-dd-HH}.log">
			<PatternLayout
				pattern="%date{yyyy-MM-dd HH:mm:ss.SSS} %level [%thread][%file:%line] - %msg%n" />
			<Policies>
				<TimeBasedTriggeringPolicy interval="1"
					modulate="true" />
			</Policies>
		</RollingRandomAccessFile>
	</appenders>
	<loggers>
		<!-- 3rdparty Loggers -->
		<logger name="org.springframework.core" level="info">
		</logger>
		<logger name="org.springframework.beans" level="info">
		</logger>
		<logger name="org.springframework.context" level="info">
		</logger>
		<logger name="org.springframework.web" level="info">
		</logger>
		<logger name="org.jboss.netty" level="warn">
		</logger>
		<logger name="org.apache.http" level="warn">
		</logger>
		<logger name="com.allcam.uas" level="info">
		</logger>
		<!-- APP Stat logger -->
		<logger name="com.allcam.uas" level="error"
			additivity="false">
			<appender-ref ref="ProductLog" />
		</logger>
		<!-- Root Logger -->
		<root level="ERROR">
			<appender-ref ref="DevLog" />
			<appender-ref ref="Console" />
		</root>
	</loggers>
</configuration>

logbak

 

共有 人打赏支持
yizhichao
粉丝 11
博文 294
码字总数 266067
×
yizhichao
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
打赏人
留言
* 支付类型
微信扫码支付
打赏金额:
已支付成功
打赏金额: