Martin Cooper wrote:

This sure doesn't sound like Commons Logging would be "an ultra-thin
bridge between different logging libraries" any more.

http://jakarta.apache.org/commons/logging/

This sounds more like a different package altogether. IMO, we have
enough trouble as it is with some people resisting adding a dependency
on Commons Logging that the last thing I want to see is a bunch more
functionality - and size - added to this component.

--
Martin Cooper


I think Log4J does support internationalization of log messages, so I think the (important) goal of remaining an "ultra-thin bridge" is maintained. To support this added functionality, perhaps a sub-interface of Log could be used like this:

private static final LocalLog = (LocalLog) LogFactory.getLog(MyClass.class);

If the underlying logging implementation is not able to return a LocalLog, a runtime exception is thrown.

(Here's the JavaDoc that leads me to believe i18n is supported by Log4J)
http://logging.apache.org/log4j/docs/api/org/apache/log4j/Category.html#l7dlog(org.apache.log4j.Priority,%20java.lang.String,%20java.lang.Object[],%20java.lang.Throwable)

Also, regarding David's post (below), I couldn't agree more. I think a generic log.finest is more appropriate than forcing log messages to contain class and method information. If you want log.enter and log.exit, make your own wrapper Log implementation or a simple static utility function like MyLogHelper.enter(log, "MyClass", "MyMethod", "Entering memthod")

Regarding the addition of "entry/exit" logging APIs, I'm also in favour.
The code seems trivial, and it can be mapped to "TRACE" level for
logging implementations that don't provide "FINER" equivalents. It also
seems to me that:
  log.enter("MyClass", "MyMethod", "Entering method");
is nice and readable.


Until you refactor the class name or method name.  Then your logging code
is completely misleading.  Considering the fact that IDEs allow you to
rename things without even looking at their implementation code, the
chance of the logging not keeping up with the names is high.

I would personally never use the enter/exit methods for those reasons.  If
I wanted that kind of detail, I would use AspectJ.

David





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to