0

这是我的 logback.xml 配置

<?xml version="1.0" encoding="UTF-8"?>
<configuration>

    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>%d{yyyyMMdd HH:mm:ss.SSS} [%thread] %-3level %logger{5} - %msg %n</pattern>
        </encoder>
    </appender>

    <include resource = "org/springframework/boot/logging/logback/base.xml"></include> -->

    <logger name="jdbc.sqlonly" level="DEBUG"/>
    <logger name="jdbc.sqltiming" level="INFO"/>
    <logger name="jdbc.audit" level="OFF"/>
    <logger name="jdbc.resultset" level="ERROR"/>
    <logger name="jdbc.resultsettable" level="ERROR"/>
    <logger name="jdbc.connection" level="OFF"/>

    <root level="OFF">
        <appender-ref ref="STDOUT" />
    </root>

</configuration>

如您所见,我关闭了审核和连接的级别。但我可以看到审计日志一直在显示。我是否遗漏了某些东西或配置错误?

DEBUG: adminMapper.readAll - <==      Total: 5
DEBUG: jdbc.resultset - 2. ResultSet.close() returned void  sun.reflect.NativeMethodAccessorImpl.invoke0(null:-2)
DEBUG: jdbc.audit - 2. PreparedStatement.getConnection() returned net.sf.log4jdbc.sql.jdbcapi.ConnectionSpy@31a5f9af  sun.reflect.NativeMethodAccessorImpl.invoke0(null:-2)
DEBUG: jdbc.audit - 2. Connection.getMetaData() returned com.mysql.cj.jdbc.DatabaseMetaDataUsingInfoSchema@7e246793  org.apache.ibatis.executor.resultset.DefaultResultSetHandler.getNextResultSet(DefaultResultSetHandler.java:258)
DEBUG: jdbc.audit - 2. PreparedStatement.getMoreResults() returned false  sun.reflect.NativeMethodAccessorImpl.invoke0(null:-2)
DEBUG: jdbc.audit - 2. PreparedStatement.getUpdateCount() returned -1  sun.reflect.NativeMethodAccessorImpl.invoke0(null:-2)
DEBUG: jdbc.audit - 2. PreparedStatement.isClosed() returned false  sun.reflect.NativeMethodAccessorImpl.invoke0(null:-2)
DEBUG: jdbc.audit - 2. PreparedStatement.close() returned   sun.reflect.NativeMethodAccessorImpl.invoke0(null:-2)
DEBUG: org.mybatis.spring.SqlSessionUtils - Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@3b5d92df]
DEBUG: org.springframework.jdbc.datasource.DataSourceUtils - Returning JDBC Connection to DataSource
INFO : jdbc.connection - 2. Connection closed  org.springframework.jdbc.datasource.DataSourceUtils.doCloseConnection(DataSourceUtils.java:343)
DEBUG: jdbc.connection - open connections:  none
DEBUG: jdbc.audit - 2. Connection.close() returned
4

1 回答 1

0

您是否尝试过仅评论该行?我通过 application.properties 控制我的日志记录,以下对我有用:

# log4jdbc logging
# ================
logging.level.jdbc.sqltiming=debug
logging.level.jdbc.resultsettable=info


# other options...
logging.level.jdbc.sqlonly=debug
#logging.level.jdbc.audit=debug
#logging.level.jdbc.resultset=debug
#logging.level.jdbc.resultsettable=info
#logging.level.jdbc.connection=debug
于 2018-10-12T01:42:03.327 回答