You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Mark Derricutt <ma...@talios.com> on 2008/08/07 04:01:24 UTC

Per-logger/category configuration

Hey all,

I'm trying to sort out some of our logging issues when using sling and sling
logging (2.0.2-incubator).

I can happily store a configuration for the PID
org.apache.sling.commons.log.LogManager moving everything to WARN etc., but
we really only want to move certain categories to WARN.

Looking at the configuration management console I see theres two additional
logging related configurations available:

- org.apache.sling.commons.log.LogManager.factory.config
- org.apache.sling.commons.log.LogManager.factory.writer

If I store a configuration against
org.apache.sling.commons.log.LogManager.factory.config I see it stored, but
its not being bound to anything and not used.

Is this functionality not yet available, or do I need a newer sling-logging
dependency?

Also, is it possible to configure additional appenders (such as the SMTP
appender)?

Mark

-- 
"It is easier to optimize correct code than to correct optimized code." --
Bill Harlan

Re: Per-logger/category configuration

Posted by Felix Meschberger <fm...@gmail.com>.
Hi Mark,

Unfortunately this is still pending documentation (see SLING-525).

Mark Derricutt schrieb:
> Hey all,
> 
> I'm trying to sort out some of our logging issues when using sling and sling
> logging (2.0.2-incubator).
> 
> I can happily store a configuration for the PID
> org.apache.sling.commons.log.LogManager moving everything to WARN etc., but
> we really only want to move certain categories to WARN.
> 
> Looking at the configuration management console I see theres two additional
> logging related configurations available:
> 
> - org.apache.sling.commons.log.LogManager.factory.config
> - org.apache.sling.commons.log.LogManager.factory.writer
> 
> If I store a configuration against
> org.apache.sling.commons.log.LogManager.factory.config I see it stored, but
> its not being bound to anything and not used.
> 

Point is that configuration for loggers is split in three parts: the 
global configuration (LogManager), the log writer (currently only files 
are supported) and the logger configuration.

For logger specific logging you first have to create a log writer 
(...writer configuration) specifying the log file (unless you just want 
to setup category levels for use with the global log file).

Next is to create the logger configurations (....config configuration). 
One point in the logger configuration is the reference to the log writer 
to be used. You have two options to specifying this: Either using the 
configured name of file to which the logger writer writes (e.g. 
logs/error.log) or the configuration PID of the logger writer configuration.

Having these two in place should do the trick.

After all, I perfectly understand, that this is currently rather tricky 
and I intend to add a web console management plugin to more easily 
manage logging.


> Is this functionality not yet available, or do I need a newer sling-logging
> dependency?

Yes, it should be available and working in the released version 
2.0.2.incubator of the Sling logging bundle.

> 
> Also, is it possible to configure additional appenders (such as the SMTP
> appender)?

Currently only file system output is supported. Any enhancement patch to 
also support SMTP (or others like SNMP or syslogd) is of course very 
welcome.

Hope this helps.

Regards
Felix

[1] https://issues.apache.org/jira/browse/SLING-525