mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Niklas Therning <nik...@trillian.se>
Subject Re: SessionLog annoyance
Date Tue, 12 Dec 2006 06:58:58 GMT
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.PREFIX, "[" +
session.getRemoteAddress() + "] ");

See the source code of SessionLog for more info on how it works:
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:



Niklas Therning

View raw message