mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Corey Puffalt" <cpli...@gmail.com>
Subject Re: SessionLog annoyance
Date Wed, 13 Dec 2006 15:59:05 GMT
Thanks for your reply.  I had looked at the source code but for some reason
it hadn't occurred to me that I could override the default by setting the
session attributes. :P

Corey

On 12/11/06, Niklas Therning <niklas@trillian.se> wrote:
>
> Yeroc wrote:
> > Hello...
> >
> > First of all, thanks for the great work on Mina.  I've just started
> using it
> > on a small project and am finding it quite useful.
> >
> > There is one thing that annoys me and that is logging.  The SessionLog
> class
> > logs all messages using the Logger classname of my IoHandler.  This
> presents
> > a problem for me in that I can no longer differentiate log messages
> emitted
> > from the SessionLog class versus log messages emitted from my own
> IoHandler
> > class.  Furthermore, I can't filter the log messages emitted by
> SessionLog
> > (which are generally less useful to me) without also filtering the
> logging
> > output from my own IoHandler class.
> >
> > The only workaround I can see is to use a different Logger name for my
> > IoHandler class but the problem is that our standard is to always use
> the
> > classname as the Logger -- changing it to something else will just
> create
> > confusion.
> >
> > Would the developers consider modifying the SessionLog class to use some
> > other name for the Logger?
> >
> >
> You can change the name of the logger used by SessionLog in your
> IoHandler's sessionCreated() like this:
>
> public void sessionCreated(IoSession session) {
>     session.setAttribute(SessionLog.LOGGER,
> LoggerFactory.getLogger("my.logger"));
>     session.setAttribute(SessionLog.PREFIX, "[" +
> session.getRemoteAddress() + "] ");
> }
>
> See the source code of SessionLog for more info on how it works:
>
> http://svn.apache.org/viewvc/mina/tags/1.0.1/core/src/main/java/org/apache/mina/util/SessionLog.java?view=markup
> If you look at this code you will understand why you must set the prefix
> yourself if you change the logger.
>
> There's also an issue in JIRA which deals with the LoggingFilter and
> SessionLog. Setting the name of the logger and the prefix will be a lot
> easier in MINA 2.0:
>
> http://issues.apache.org/jira/browse/DIRMINA-314
>
> HTH
>
> --
> Niklas Therning
> www.spamdrain.net
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message