gavenkoa
gavenkoa

Reputation: 48843

Disable logging of Spring Batch SQL queries

How can I disable logging of Spring Batch SQL queries?

They are logged from org.springframework.jdbc.core.JdbcTemplate logger because of:

logging.level:
  org.springframework.jdbc: TRACE

and look like:

2017-05-27 20:41:55.957 DEBUG 13088 --- [jobLauncherTaskExecutor-1] o.s.jdbc.core.JdbcTemplate               : Executing prepared SQL update
2017-05-27 20:41:55.957 DEBUG 13088 --- [jobLauncherTaskExecutor-1] o.s.jdbc.core.JdbcTemplate               : Executing prepared SQL statement [UPDATE BATCH_JOB_EXECUTION_CONTEXT SET SHORT_CONTEXT = ?, SERIALIZED_CONTEXT = ? WHERE JOB_EXECUTION_ID = ?]
2017-05-27 20:41:55.958 DEBUG 13088 --- [jobLauncherTaskExecutor-1] o.s.jdbc.core.JdbcTemplate               : SQL update affected 1 rows

With such enormous amount of these messages I can't see my application messages (that have matter).

The problem is that by disabling this logger my application SQL queries will also be disabled.

Upvotes: 0

Views: 1904

Answers (1)

Sabir Khan
Sabir Khan

Reputation: 10142

You have not specified what logging framework you use.

I have managed this in my Spring Batch application using logback.

I define a separate logger for my application and rest is default logger then I can separately set logging levels for both different loggers.

Please refer my slideshare presentation to get some ideas about defining named loggers in logback.

To address,

With such enormous amount of these messages I can't see my application messages

I guess, whatever logging framework you use, the idea basic is to define a separate logger for your application needs and directing rest to a default logger then setting levels separately i.e. logging at package level wouldn't help here.

The other solution like the one mentioned in accepted answer here will disable logs for your queries too.

Upvotes: 1

Related Questions