Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change log4j setting during application run?

Tags:

java

log4j

Is it possible to change log4j settings during application execution?

like image 560
Worker Avatar asked Feb 22 '11 07:02

Worker


2 Answers

You can use PropertyConfigurator.configureAndWatch to make log4j spawn a thread to periodically check your properties file for changes.

Alternatively, you can use JMX described in this post: Change Logging Levels using JMX

like image 160
dogbane Avatar answered Sep 16 '22 15:09

dogbane


There ways of doing this by making your Log4j accessible through JMX and using a JMX console to control the filters, loggers, levels, appenders etc...

I have an example somewhere but I need to prune it a little to make it understandable. Would you want this ?

like image 37
Alain Pannetier Avatar answered Sep 18 '22 15:09

Alain Pannetier