Erik Sapir
Erik Sapir

Reputation: 24707

Java tomcat - how to remove JDBC debug logs

The following log is constantly thrown to the console:

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

How can i stop these logs/Change the logging level to INFO or ERROR?

Upvotes: 1

Views: 2347

Answers (1)

Tomasz Nurkiewicz
Tomasz Nurkiewicz

Reputation: 340708

Are you using Logback or Log4J? Do you have any configuration file in your application? Try placing this in 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>

If you already found logback.xml file in your application, just add the <logger... line.

However if you found log4j.xml in the directory above, add this lines to it instead:

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

Upvotes: 1

Related Questions