log4j经常使用到的两个日志文件log4j.properties和log4j.xml

艾星河
2023-12-01

java开发过程中 debug时必须用到的,这里记录下两个经常使用到的log4j文件,备忘

log4j.xml 修改日志级别,可以查看sql的执行

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="[%d{yy/MM/dd HH:mm:ss:SSS}] %5p %c{2}: %m%n" />
</layout>
</appender>
<appender name="FILE" class="org.apache.log4j.RollingFileAppender">
<param name="file" value="${user.home}/foss-framework.log" />
<param name="append" value="true" />
<param name="maxFileSize" value="10MB" />
<param name="maxBackupIndex" value="100" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d [%t] %-5p %C{6} (%F:%L) - %m%n" />
</layout>
</appender>
<logger name="jdbc.sqltiming">         
<level value="INFO" />     
</logger>
<logger name="jdbc.connection">         
<level value="ERROR" />     
</logger>
<logger name="jdbc.resultset">
<level value="ERROR"/>
</logger>
<logger name="jdbc.audit">
<level value="ERROR"/>
</logger>
<logger name="jdbc.sqlonly">
<level value="ERROR"/>
</logger>
<logger name="jdbc.resultsettable" additivity="false"> 
<level value="ERROR" /> 
<appender-ref ref="CONSOLE" /> 
</logger>
  <root>
<level value="INFO" />
<appender-ref ref="CONSOLE" />
</root>
</log4j:configuration>


log4j.properties

log4j.rootCategory=ERROR,console,ROOT_APPENDER


log4j.appender.ROOT_APPENDER.encoding=UTF-8
log4j.appender.ROOT_APPENDER=org.apache.log4j.DailyRollingFileAppender
log4j.appender.ROOT_APPENDER.datePattern='.'yyyy-MM-dd
log4j.appender.ROOT_APPENDER.File=../server/default/log/call.log
log4j.appender.ROOT_APPENDER.layout=org.apache.log4j.PatternLayout
log4j.appender.ROOT_APPENDER.layout.ConversionPattern=[%d %5p]%m( %c.%M:%L)%n




log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=[%d %5p]%m( %c.%M:%L)%n




##disable log
log4j.logger.jdbc=ERROR
########接口日志配置#########
#foss模块日志等级设定
log4j.logger.com.deppon.cc.module.foss=debug
#crm模块日志等级设定
log4j.logger.com.deppon.cc.module.crm=debug
#短信模块日志等级设定
log4j.logger.com.deppon.cc.module.sms=debug
#esb模块日志等级设定
log4j.logger.com.deppon.esb.util=debug
#call-web模块日志
log4j.logger.com.deppon.cc.module.custmanager=debug
#单点登录模块日志
log4j.logger.com.deppon.foss.framework.server.sso.SSOManager=debug

 类似资料: