Logging is a very important utility for software. We want to use logging to debug at development, save infomation at product run time.
Here I will share to you how to use Apache Log4J to do two things, asynchronized logger and dynamic desired logger level.

Asynchronized logger:
1. Apache Log4J supports for the console, files, GUI components, remote socket servers, JMS, NT Event Loggers,
and remote UNIX Syslog daemons. It is also possible to log asynchronously.
Ref: Log4J official document

2. Log4J offers JMXAppender, so we can use P2P queue for logging by JMS provider.
Ref: JMXAppender example

3. Develop an Asynchronous Logging Framework using log4j with JMS and WebSphere MQ

Dynamic desired logger level:
1. Log4J also can be configed by JMX(MBean). If you use Spring framework, then Spring supports JMX, so we can explore Log4J MBean to change its logging level dynamically.
Ref:
Spring framework – JMX
Extending Spring JMX support
Modify Spring Beans and Log4j levels on a running server with JMX and JConsole
JMX meets Log4J
Extending Spring JMX support-Customize resource management with the Spring framework

Learning JMX:
Getting Started with Java Management Extensions (JMX)
Java Management Extensions (JMX) – Best Practices
JBoss 4.x: Using JMX as a Microkernel
Spring 2.x: JMX

Advertisements