p6spy / p6spy

P6Spy is a framework that enables database data to be seamlessly intercepted and logged with no code changes to the application.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Excluded SQL statement generates a log entry

mardukbp opened this issue · comments

I am running p6spy 3.9.1 to monitor the connection from a JBoss application to an Oracle database. The spy.properties file contains the following:

customLogMessageFormat=%(sql)
...
filter=true
exclude=USERSESSIONS

The application generates many SQL queries involving the USERSESSIONS table, which are not relevant to my analysis. Even though I excluded them, p6spy prints a newline every time such a query is captured (since the log message is empty), which pollutes the log file.

Is there a configuration option I could use to prevent this other than setting logMessageFormat to a custom class?

I do not know if this is the intended behavior, but it contradicts my expectation of how exclude should work.

Update: Using %(sqlSingleLine) makes no difference.

Update 2: I implemented the following appender

public class SilentFileLogger extends FileLogger {
    @Override
    public void logText(String text) {
        if (!text.trim().isEmpty()) {
            getStream().println(text);
        }
    }
}

Is there any objection to making this the default behavior?

@mardukbp I think it would be a good idea to make this one a default. Any chance to implement !text.trim().isEmpty() check for all the available P6Logger implementations?

Any chance for pull request from your side?