mybatis怎么配置log4j打印出sql语句
展开全部
<!-- SQL日志 -->
<appender name="sqlLogAppender" class="com.qunar.flight.log4j.DailyRollingFileAppender">
<param name="File" value="${catalina.base}/logs/mybatis.log"/>
<param name="Encoding" value="UTF-8" />
<param name="DatePattern" value="'.'yyyy-MM-dd-HH'.log'" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss,SSS} %p [%t][%X{traceId} %X{uid}] %x - %m%n" />
</layout>
</appender>
<logger name="java.sql" additivity="true">
<level value="DEBUG" />
<appender-ref ref="sqlLogAppender" />
</logger>
<logger name="com.ibatis" additivity="true">
<level value="DEBUG" />
<appender-ref ref="sqlLogAppender" />
</logger>
<appender name="sqlLogAppender" class="com.qunar.flight.log4j.DailyRollingFileAppender">
<param name="File" value="${catalina.base}/logs/mybatis.log"/>
<param name="Encoding" value="UTF-8" />
<param name="DatePattern" value="'.'yyyy-MM-dd-HH'.log'" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss,SSS} %p [%t][%X{traceId} %X{uid}] %x - %m%n" />
</layout>
</appender>
<logger name="java.sql" additivity="true">
<level value="DEBUG" />
<appender-ref ref="sqlLogAppender" />
</logger>
<logger name="com.ibatis" additivity="true">
<level value="DEBUG" />
<appender-ref ref="sqlLogAppender" />
</logger>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询