You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "Maarten Bosteels (JIRA)" <ji...@apache.org> on 2007/09/28 21:31:50 UTC

[jira] Resolved: (DIRMINA-445) SessionLog improvement

     [ https://issues.apache.org/jira/browse/DIRMINA-445?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Maarten Bosteels resolved DIRMINA-445.
--------------------------------------

       Resolution: Fixed
    Fix Version/s: 2.0.0-M1

Applied change proposed by Emmanuel Lecharny 

Please note that in the comments I mistakenly used the term "Marker mechanism" when I meant
the methods that take a format parameter that contains {} placeholders .

Apparently Marker's are a different concept: http://www.slf4j.org/api/org/slf4j/Marker.html


> SessionLog improvement
> ----------------------
>
>                 Key: DIRMINA-445
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-445
>             Project: MINA
>          Issue Type: Improvement
>          Components: Core
>    Affects Versions: 1.1.3, 2.0.0-M1
>         Environment: Use Object instead of String inSessionLog logging method to allow for massive perfs improvement on production running instances (when logs filtering is used).
>            Reporter: vincent bourdaraud
>            Assignee: Maarten Bosteels
>            Priority: Minor
>             Fix For: 2.0.0-M1
>
>
> SessionLog.debug(IoSession,String), info(IoSession,String), warn(IoSession,String) and error(IoSession,String) should be changed to SessionLog.debug(IoSession,Object), info(IoSession,Object), warn(IoSession,Object) and error(IoSession,Object), as in log4j.
> The reason for this is that if passing Objects instead of String allow to delay the composition of the logging message (.toString() call) until really needed and that could greatly improve performance. This kind of feature is needed to build SW able to be turned in debug while in production using NDC/MDC filters (using log4j e.g.).
> Some code snippet the illustrate this:
>     public void messageReceived(IoSession session, Object o) throws Exception
>     {
>        MyProtocolRequest req = (MyProtocolRequest) o;
>        NDC.put(req.getUserId());
>        SessionLog.debug(session, new RequestDumper(req));
>        NDC.pop();
>     }
>    
>     class RequestDumper()
>     {
>         public RequestDumper(MyProtocolRequest req)
>         {
>             this.req = req;
>         }
>         
>         public String toString()
>         {
>             return req.toString();
>         }
>         
>         private MyProtocolRequest req;
>     }
> In that snippet, the cost of converting MyProtocolRequest to a String is not paied when SessionLog.debug() is called, but when the underlying logging framework needs the string for logging. The perf improvement could be massive if the underlying protocol uses some kind of filtering to filter-out most debug logs; in that example, the logging framework would be configured to filter-in only logs with a NDC set to a specific user.
> With this feature, we could enable debug in production for some few users only, without killing the overall performances.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.