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

Turn on/off spy logging dynamically #496

Open
sadaaithal opened this issue Mar 26, 2020 · 6 comments
Open

Turn on/off spy logging dynamically #496

sadaaithal opened this issue Mar 26, 2020 · 6 comments

Comments

@sadaaithal
Copy link

I wanted to have a way of stopping the spy logging dynamically.
My application is non-jmx based so i provide the p6spy options at startup.
By default the p6spy log file starts from process init.
Some of my tests start a long time after startup - and by then the spy log file is in the GBs.
I will have to regularly truncate this file to not hit other disk/io issues.

So is there a way we can introduce an option to enable/disable spy logging controllable via the spy.properties file?
I came across this https://sourceforge.net/p/p6spy/discussion/162085/thread/50d50cfe/
Turns out "trace=false" is no longer recognized by p6spy-3.8.7.jar.

@sadaaithal sadaaithal changed the title Turn on/off spy logging on the fly Turn on/off spy logging dynamically Mar 26, 2020
@typekpb
Copy link
Member

typekpb commented Mar 27, 2020

is your actual problem, that the log file is taking too much space? if so, you can still handle it on a level of logging library and respective rollout policy, I believe.

@sadaaithal
Copy link
Author

sadaaithal commented Mar 27, 2020 via email

@typekpb
Copy link
Member

typekpb commented Apr 4, 2020

@sadaaithal currently there is no such functionality I can think of :(

@typekpb
Copy link
Member

typekpb commented Apr 4, 2020

any chance to prvovide Pull request? as I have no chance to do so, due to very limited time I have available for the project.

@avrecko
Copy link

avrecko commented Jul 6, 2023

I have the same use case for file appender in tests. I just created a custom appender that extends FileLogger and have a global on off switch.

CustomFileLogger.enable() / disable()

not a big deal if this doesn't come with the project. Took me like 5 minutes to get it done. Maybe I'll add a pull request.

Alternatively without code changes, with slf4j appender it should already be possible to enable/disable logger in runtime via logger implementation.

@fatso83
Copy link

fatso83 commented Nov 23, 2023

If you use Log4J or similar you can just disable the logger like this:

<Logger name="p6spy" level="OFF"/> <!-- prints time spent on every SQL query -->

If you are developing and want to quickly enable/disable you can then either use JMX to configure the logger or just enable <Configuration monitorInterval="5"> to have Log4J auto-reload the config every now and then.

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

No branches or pull requests

4 participants