mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Maarten Bosteels" <mbosteels....@gmail.com>
Subject Re: result poll logging frameworks
Date Wed, 10 Oct 2007 13:59:46 GMT
On 10/8/07, Trustin Lee <trustin@gmail.com> wrote:
> On 10/8/07, Maarten Bosteels <mbosteels.dns@gmail.com> wrote:
> > Hello community,
> >
> > Thanks for participating in the poll. Here are the results:
> >
> > log4j:  14
> > logback: 4
> > slf4j-simple:  3
> > slf4j-nop:  2
> > java.util.logging: 1
> >
> > 8 people are using exclusively log4j
> > 3 people are using exclusively logback
> > 1 person is using exclusively java.util.logging
> >
> > Everybody using slf4j-simple or slf4j-nop is also using log4j.
> > I suppose these people use log4j in production, and slf4j-simple or slf4j-nop
> > during development, right ?
> >
> > That would mean that there is only one poor soul (sorry Steven E. Harris :-) )
> > that can't use the MDC feature.
> >
> > Trustin, maybe we should reopen the discussion about removing IoSessionLogger
> > in favour of MdcInjectionFilter :-)
>
> Well, there's at least one person who's using java.util.logging in the
> mailing list, and there should be more people who's not in here.  If
> we are going to drop good support for JUL, what is the use of SLF4J?

Well, SLF4J gives people choice and it still would, people could still choose
any of the supported logging systems, BUT when the logging framework
of their choice doesn't support MDC, they wouldn't see the
remoteAddress in their logs.
But ok, I can understand that you find that unacceptable.

On the other hand, I would prefer if logging events generated by
ProtocolCodecFilter
would have org.apache.mina.filter.codec.ProtocolCodecFilter as their logger.
I know this is not required but it is a very widely used convention.

I thought of another solution:

* the MdcInjectionFilter stores the remoteAddress in a ThreadLocal
* we create a decorator for org.slf4j.Logger that retrieves the
remoteAddress from the ThreadLocal and prepends it to the log-message
(optionally of course, only needed when the logging framework doesn't
support MDC)
* all mina-classes use this decorator instead of IoSessionLogger

I haven't tried this idea, but I think it would work ok.
Normally, I am wary of using ThreadLocal's but for logging I consider
it acceptable.

In fact, I think this functionality could be added to SLF4J to make
all SLF4J implementations MDC-capable. I'll ask Ceki what he thinks
about it.

If you want me to shut up about IoSessionLogger and just keeps things
as they are, just tell me, I won't be offended ;-)

(of course, when we keep things as they are, the MdcInjectorFilter
should remove the PREFIX from the IoSession, as discussed before)

Maarten

Mime
View raw message