ibaits中进行log4j控制台输出

IBATIES在控制台输出SQL语句2008-09-09 21:54HIBERANTE有这样的功能,那么IBATIES也不能例外,不过它输出要依靠LOG4J,而不是自己配置自己的文件。配置LOG4J内容 LOG4J.properties

## LOGGERS ##
#define a logger named helloAppLogger
log4j.rootLogger=INFO,console

## APPENDERS ##
# define an appender named console, which is set to be a ConsoleAppender
log4j.appender.console=org.apache.log4j.ConsoleAppender

## LAYOUTS ##
# assign a SimpleLayout to console appender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=[%p-%d{yyyy/MM/dd/HH:mm:ss}]%c{1}.%m(%L) - %m%n

# SqlMap logging configuration...  
#log4j.logger.com.ibatis=debug
#log4j.logger.com.ibatis.common.jdbc.SimpleDataSource=debug
#log4j.logger.com.ibatis.common.jdbc.ScriptRunner=debug
#log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=debug
log4j.logger.java.sql.Connection=debug
log4j.logger.java.sql.Statement=debug
log4j.logger.java.sql.PreparedStatement=debug


log4j.xml

<appender name="IBatis" class="org.apache.log4j.ConsoleAppender">
   <layout class="org.apache.log4j.PatternLayout">
    <param name="ConversionPattern"
     value="%-4r [%t] %-5p %c %x - %m%n" />
   </layout>
   <filter class="org.apache.log4j.varia.LevelRangeFilter">
    <param name="LevelMin" value="DEBUG" />
    <param name="LevelMax" value="DEBUG" />
   </filter>
</appender>

<logger name="com.ibatis" additivity="true">
   <level value="DEBUG" />
</logger>

<logger name="java.sql.Connection" additivity="true">
   <level value="DEBUG" />
</logger>

<logger name="java.sql.Statement" additivity="true">
   <level value="DEBUG" />
</logger>

<logger name="java.sql.PreparedStatement" additivity="true">
   <level value="DEBUG" />
   <appender-ref ref="IBatis" />
</logger>

<logger name="java.sql.ResultSet" additivity="true">
   <level value="DEBUG" />
   <appender-ref ref="IBatis" />
</logger>

你可能感兴趣的:(java,sql,log4j,ibatis,jdbc)