On 04.12.2012 19:18, Jason van Zyl wrote:

> I've been talking to Ceki about configuration in SLF4J as there is
> really no way to change the log level without assuming an
> implementation. If that's the way then for embedding the user can
> change the SLF4J implementation but for the CLI this will not be
> possible. What I would effectively have to do is what the Sonar folks
> did which is to grab hold of the implementation and programmatically
> change the log level.
>
> So if the default log level is INFO I don't think it's possible to
> ship all implementations and be able to flip to debug mode easily. So
> I think if we pick one implementation then for the CLI we can make
> that assumption. Again this should not affect folks who embed like m2e
> as we just use the components and do our own SLF4J integration.

It would be possible to set the level of a logger by invoking
framework-specific directives. Here is some pseudo-code:

// pseudo code
public void setLevel(Logger logger, int level) {
  if(logger instanceof org.apache.log4j.Logger) {
    log4jSetLevel(logger, level);
  } else if(logger instanceof ch.qos.logback.classic.Logger) {
    logbackSetLevel(logger, level);
  } else if (logger instanceof java.util.logging.Logger) {
    julSetLevel(logger, level);
  } else if (you get the idea...) {
    ...
  }
}

Historically, SLF4J has shied away from providing abstractions for
logging configuration for two reasons:

1) logging configuration can have quite a large scope.
2) insufficient demand

If the scope of "configuration" is limited to logger level
configuration, the problem becomes much easier to tackle as
illustrated by the pseudo code above. Would Maven's logging
configuration requirements be satisfied by logger level configuration
or are there requirements beyond logger level configuration?

By the way, the is no reason why Maven could not implement similar
level configuration code on its own without depending on a slf4j
configuration module which currently does not exist.

--
Ceki
http://twitter.com/#!/ceki

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to