You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Bertrand Delacretaz <bd...@apache.org> on 2012/11/19 17:54:06 UTC
No two loggers with the same category, why?
Hi,
The code below [1] was introduced in for SLING-525, and prevents
creating two loggers that have one or more log categories in common -
do we really want that?
I'm looking at implementing support for slf4j Markers, which allows
for "orthogonal" log configurations, for example:
a) Send all INFO and higher logs to info.log
b) Send all DEBUG and higher logs which have a FOO marker to foo.log
(useful to keep track of processes spread around several services for
example)
And that gets in the way.
-Bertrand
[1] From
http://svn.apache.org/repos/asf/sling/trunk/bundles/commons/log/src/main/java/org/apache/sling/commons/log/internal/slf4j/LogConfigManager.java
// verify no other configuration has any of the categories
for (String cat : categories) {
SlingLoggerConfig cfg = configByCategory.get(cat);
if (cfg != null && !pid.equals(cfg.getConfigPid())) {
throw new ConfigurationException(LogManager.LOG_LOGGERS,
"Category " + cat
+ " already defined by configuration " + pid);
}
}
Re: No two loggers with the same category, why?
Posted by Bertrand Delacretaz <bd...@apache.org>.
On Mon, Nov 19, 2012 at 5:54 PM, Bertrand Delacretaz
<bd...@apache.org> wrote:
> ...The code below [1] was introduced in for SLING-525, and prevents
> creating two loggers that have one or more log categories in common -
> do we really want that?...
I'm revisiting this...just so that the list archives are complete:
this is also needed because loggers are acquired via the
org.slf4j.ILoggerFactory interface:
/* Return an appropriate Logger instance as specified by the name
parameter. */
Logger getLogger(String name)
So we need a 1-to-1 mapping of a log category (name) to Logger.
Or something more clever that aggregates Loggers which share
categories, but that's probably going too far.
-Bertrand
Re: No two loggers with the same category, why?
Posted by Felix Meschberger <fm...@adobe.com>.
Hi,
Am 21.11.2012 um 11:35 schrieb Bertrand Delacretaz:
> Hi Felix,
>
> On Wed, Nov 21, 2012 at 11:18 AM, Felix Meschberger <fm...@adobe.com> wrote:
>> ...Each logger (SlingLogger) is associated with a single configuration
>> (SlingLoggerConfig), which in turn defines the log level and target for that logger.
>> So currently it is not possible to associate a logger with more than one configs....
>
> Ok, but how about several SlingLoggerConfigs having log categories in common?
>
> IIUC the current code disallows that, and I don't see why.
Because each logger -- e.g. org.apache.sling.engine.impl -- is backed by a SlingLogger instance which is connect to a single SlingLoggerConfig, which defines which level written to which writer.
So, because the SlingLogger instances don't support it we prevent it.
If you want to improve, I suggest you would probably create SlingLoggerConfig instances for each level/writer combo and have support for SlingLogger instances to be related to more than one SlingLoggerConfig.
Regards
Felix
Re: No two loggers with the same category, why?
Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi Felix,
On Wed, Nov 21, 2012 at 11:18 AM, Felix Meschberger <fm...@adobe.com> wrote:
> ...Each logger (SlingLogger) is associated with a single configuration
> (SlingLoggerConfig), which in turn defines the log level and target for that logger.
> So currently it is not possible to associate a logger with more than one configs....
Ok, but how about several SlingLoggerConfigs having log categories in common?
IIUC the current code disallows that, and I don't see why.
-Bertrand
Re: No two loggers with the same category, why?
Posted by Felix Meschberger <fm...@adobe.com>.
Hi,
Each logger (SlingLogger) is associated with a single configuration (SlingLoggerConfig), which in turn defines the log level and target for that logger. So currently it is not possible to associate a logger with more than one configs.
Of course, we can enhance this and support multiple configurations to which a logger will send messages.
Regards
Felix
Am 19.11.2012 um 17:54 schrieb Bertrand Delacretaz:
> Hi,
>
> The code below [1] was introduced in for SLING-525, and prevents
> creating two loggers that have one or more log categories in common -
> do we really want that?
>
> I'm looking at implementing support for slf4j Markers, which allows
> for "orthogonal" log configurations, for example:
>
> a) Send all INFO and higher logs to info.log
>
> b) Send all DEBUG and higher logs which have a FOO marker to foo.log
> (useful to keep track of processes spread around several services for
> example)
>
> And that gets in the way.
>
> -Bertrand
>
>
>
> [1] From
> http://svn.apache.org/repos/asf/sling/trunk/bundles/commons/log/src/main/java/org/apache/sling/commons/log/internal/slf4j/LogConfigManager.java
>
> // verify no other configuration has any of the categories
> for (String cat : categories) {
> SlingLoggerConfig cfg = configByCategory.get(cat);
> if (cfg != null && !pid.equals(cfg.getConfigPid())) {
> throw new ConfigurationException(LogManager.LOG_LOGGERS,
> "Category " + cat
> + " already defined by configuration " + pid);
> }
> }