Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not clear how to use ErrorLoggingEventListener #549

Open
cowwoc opened this issue Jul 24, 2022 · 1 comment
Open

Not clear how to use ErrorLoggingEventListener #549

cowwoc opened this issue Jul 24, 2022 · 1 comment

Comments

@cowwoc
Copy link

cowwoc commented Jul 24, 2022

I want P6Spy to log SQL warnings/exceptions. I ran across ErrorLoggingEventListener whose Javadoc recommends:

add com.p6spy.engine.logging.ErrorLoggingEventListener to the file
src/main/resources/META-INF/services/com.p6spy.engine.logging.LoggingEventListener

However, when I do this nothing gets logged. Is it possible to add error logging without disabling the default event listener?

@cowwoc
Copy link
Author

cowwoc commented Jul 24, 2022

The only way I found to make this work is using the following spy.properties configuration:

modulelist=com.p6spy.engine.logging.P6LogFactory,com.p6spy.engine.outage.P6OutageFactory,\ foobar.LogExceptionsFactory

where foobar.LogExceptionsFactory is defined as:

public final class LogExceptionsFactory implements P6Factory
{
	private static final ErrorLoggingEventListener ERROR_LOGGING_INSTANCE = new ErrorLoggingEventListener();

	@Override
	public JdbcEventListener getJdbcEventListener()
	{
		return ERROR_LOGGING_INSTANCE;
	}

	@Override
	public P6LoadableOptions getOptions(P6OptionsRepository optionsRepository)
	{
		return new P6LogOptions(optionsRepository);
	}
}

Please document the use of EventListeners. This was much harder than it should have been :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant