On 8/17/07, Trustin Lee <[EMAIL PROTECTED]> wrote:
>
> On 8/17/07, Maarten Bosteels <[EMAIL PROTECTED]> wrote:
> > Trustin.
> >
> > I like the idea, but I guess some people (like me) use the IoSession for
> > logging the remote address.
> > And I guess codec implementations will still depend on mina because of
> > ProtocolDecoderOutput, right ?
>
> Yeah, I agree with you and that's why I am asking if there's any use
> cases. :)
>
> ProtocolDecoderOutput and ProtocolEncoderOutput also doesn't have any
> dependency on IoSession or any other MINA interfaces, so protocol
> implementors will be enough with ProtocolEncoder, ProtocolDecoder,
> ProtocolEncoderOutput and ProtocolDecoderOutput.
>
> > About logging, I guess slf4j does not have something as log4j's NDC
> concept
> > ?
> > I have an IoFilter that pushes the remote address in the NDC before
> > propagating the event and pops it afterwards.
> > Very handy, because all logging events down the call stack will contain
> the
> > remote address, without depending on mina's
> > SessionLog.
>
> SLF4J doesn't support NDC, but at least it supports MDC:
>
> http://www.slf4j.org/api/org/slf4j/MDC.html
>
> IIUC, MDC or NDC should be used for purely diagnostic purpose, so I
> guess we need to provide a Map to the codec anyway. WDYT?


I  am not following you here.
Do you mean the map with session attributes that would replace the IoSession
in the decode method ?
What has it got to do with an MdcLoggingFilter ?

Oh wait, you thought I was suggesting to replace the IoSession parameter
with an NDC or MDC ?
No, no, of course, MDC/NDC is just for logging.

It 's just that I was thinking that some people would use the IoSession in
their decoder to be able to log
for which session they are decoding. And that's when I remembered my
NdcLoggingFilter.
Sorry for the confusion.

Actually I have never tried this kind of feature and that's why I was
> trying to create a new Logger class that decorates message output.  If
> we can utilize MDC, we might not need log message decoration at all.
> What was your experience?


Very good.  I first implemented it using mina 0.8 : it was very simple and
didn't have any problems.

When I switched to 2.x it was a bit more tricky because of the
ExecutorFilter in the chain:
The loggingfilter should be after the executorfilter, but then my
encoders/decoders weren't decorated.
(I had a quick and dirty fix for that, but will try to find something less
dirty ;-)

But the nice thing is that all logging events, even those generated by other
libs like spring and hibernate
all have the remote address info. IMHO that's a big advantage over a
decorator like SessionLogger.

You could grep on a specific ip address + port in the logfile and see the
complete flow for just that client.

Let me have a look at the MDC (I think it's even more convenient than NDC)
and I try to build
an MdcLoggingFilter this weekend, using SLF4J.

Maarten

Thanks,
> Trustin
> --
> what we call human nature is actually human habit
> --
> http://gleamynode.net/
> --
> PGP Key ID: 0x0255ECA6
>

Reply via email to