Sling Runtime Logging Config

10 11 2009

One of the most annoying things about bug hunting in open source, is that you can see that the developer left log.debug( statements for you in the code but you have to shutdown, reconfigure logging and restart. In Apache Sling this isnt the case. According to the documentation at you can configure logging at runtime. AND you can configure it on a class by class basis. Here are some screenshots of how.

Go to the admin console, select the configuration tab.

Picture 6

Select from the Configuration Factories drop down the logging.config Factory,

Picture 7

Set the properties including the package or class that you want this logging config to apply to, and save.

Picture 8



As I mentioned, you can do all of this on a running instance, no need to shutdown.



3 responses

10 11 2009
Anton Tagunov

Hi, can not this be done within other frameworks?

For instance Logback comes with a JMX bean
If you enable JMX remoting in your application and expose this bean you can switch logging levels at runtime just all right

I’m sure Log4j should be providing a similar facility

10 11 2009

I guess you are right it can be done with other frameworks. I haven’t noticed Log4J beans with JConsole before, but you are probably right. That does all assume that you remembered to start the JVM with JMX in the first place.

11 11 2009

JBoss comes with a JMX bean for log4j already. Don’t know about other containers, but writing your own JMX bean for log4j is trivially simple using Spring

%d bloggers like this: