[
https://issues.apache.org/jira/browse/DIRMINA-445?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12531127
]
Maarten Bosteels commented on DIRMINA-445:
------------------------------------------
I completely agree with replacing IoSessionLogger with MdcInjectionFilter
(that's why I proposed it in my first comment on this issue).
I just didn't dare to push 'my' MdcInjectionFilter too hard :-)
IMO MdcInjectionFilter has several advantages:
* all log events will contain the remoteIP, as opposed to only those created
via IoSessionLogger
(but maybe not everybody wants that ?)
* users can use all methods of org.slf4j.Logger while currently IoSessionLogger
only offers a subset
* it's an othogonal concern: remove the filter and the log-statements still work
* users can add custom session attributes to the Mdc
* users can decide how to format the IoSession attributes (remoteIp,
remotePort, ...)
> 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.