Java tomcat - 如何删除JDBC调试日志

时间:2011-08-23 06:43:39

标签: java tomcat

以下日志不断抛出到控制台:

09:36:53.456 [CloseConnectionsTimer] DEBUG o.s.jdbc.datasource.DataSourceUtils - Fetching JDBC Connection from DataSource

09:36:53.456 [CloseConnectionsTimer] DEBUG o.s.jdbc.core.StatementCreatorUtils - Setting SQL statement parameter value: column index 1, parameter value [0], value class [java.lang.Long], SQL type -5

09:36:53.456 [CloseConnectionsTimer] DEBUG o.s.jdbc.datasource.DataSourceUtils - Returning JDBC Connection to DataSource

09:36:53.472 [CloseConnectionsTimer] DEBUG o.s.jdbc.core.JdbcTemplate - Executing prepared SQL query

09:36:53.472 [CloseConnectionsTimer] DEBUG o.s.jdbc.core.JdbcTemplate - Executing prepared SQL statement..

09:36:53.472 [CloseConnectionsTimer] DEBUG o.s.jdbc.datasource.DataSourceUtils - Fetching JDBC Connection from DataSource

09:36:53.472 [CloseConnectionsTimer] DEBUG o.s.jdbc.core.StatementCreatorUtils - Setting SQL statement parameter value: column index 1, parameter value [0], value class [java.lang.Integer], SQL type 2

09:36:53.472 [CloseConnectionsTimer] DEBUG o.s.jdbc.datasource.DataSourceUtils - Returning JDBC Connection to DataSource

如何停止这些日志/将日志记录级别更改为INFO或ERROR?

1 个答案:

答案 0 :(得分:1)

您使用的是Logback还是Log4J?您的应用程序中是否有任何配置文件?尝试将其放在src/main/resources/logback.xml

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

    <logger name="org.springframework.jdbc" level="INFO" />

    <root level="ALL">
        <appender class="ch.qos.logback.core.ConsoleAppender">
            <encoder>
                <Pattern>%d{HH:mm:ss:SSS} | %-5level | %thread | %logger{20} | %msg%n</Pattern>
            </encoder>
        </appender>
    </root>
</configuration>

如果您已在应用中找到logback.xml个文件,只需添加<logger...行。

但是,如果您在上面的目录中找到log4j.xml,请将此行添加到其中:

<logger name="org.springframework.jdbc">
    <level value="INFO"/> 
</logger>