Java SDK - p6spy log file


I am using the Java SDK (latest version 5.6.1) in a Spring Boot application.
I configure the JDCB instrumentation for performance monitoring with P6Spy as per the documentation JDBC Instrumentation for Spring Boot | Sentry Documentation and the transactions are captured successfully in Sentry with the spans for database calls.

However, I noticed that a log file named spy.log is created as soon as the app is started and it grows quickly with all the details of all executed SQL queries. I could not find a way to disable the P6Spy logging to this file.

What is the way to not have this spy.log file? I would like to have only the tracing information in the Sentry spans, this log file is redundant in my view.

P6Spy by default configures file logger. One way to disable it is to configure a no-op logger:

import com.p6spy.engine.logging.Category;
import com.p6spy.engine.spy.appender.P6Logger;

public class NoOpLogger implements P6Logger {

    @Override public void logSQL(int i, String s, long l, Category category, String s1, String s2, String s3) {

    @Override public void logException(Exception e) {

    @Override public void logText(String s) {

    @Override public boolean isCategoryEnabled(Category category) {
        return false;

And then, in your main method before is called:

System.setProperty("p6spy.config.appender", NoOpLogger.class.getCanonicalName());

This property can be also set with file.

Alternatively you can configure P6Spy to use SLF4J logger:

System.setProperty("p6spy.config.appender", Slf4JLogger.class.getCanonicalName());

And configure p6spy logger level to ERROR in


Thanks for raising this question, we will update documentation.

Thanks a lot, Maciej.
The No-op logger approach with the file worked for me.

It may be worth considering having this configuration by default in the SDK, if that’s possible, as I guess most users would not need the spy.log file when using Sentry.

1 Like

We are discussing it now. Perhaps it won’t be by default, but there should be an easier way to opt-out from logging with P6Spy. I’ve also added NoOpLogger to P6Spy: Add NoOpLogger. by maciejwalkowiak · Pull Request #543 · p6spy/p6spy · GitHub - perhaps you can upvote an issue so eventually we would be able to remove this part from Sentry SDK source code.

Thanks, I upvoted both P6Spy issues (535 and 543), hope this would make it there at some point.

1 Like