You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by el...@apache.org on 2019/04/04 15:44:30 UTC

svn commit: r1856949 - /mina/site/trunk/content/mina-project/userguide/ch5-filters/ch5.9-logging-filter.mdtext

Author: elecharny
Date: Thu Apr  4 15:44:30 2019
New Revision: 1856949

URL: http://svn.apache.org/viewvc?rev=1856949&view=rev
Log:
Added the LoggingFilter page content

Modified:
    mina/site/trunk/content/mina-project/userguide/ch5-filters/ch5.9-logging-filter.mdtext

Modified: mina/site/trunk/content/mina-project/userguide/ch5-filters/ch5.9-logging-filter.mdtext
URL: http://svn.apache.org/viewvc/mina/site/trunk/content/mina-project/userguide/ch5-filters/ch5.9-logging-filter.mdtext?rev=1856949&r1=1856948&r2=1856949&view=diff
==============================================================================
--- mina/site/trunk/content/mina-project/userguide/ch5-filters/ch5.9-logging-filter.mdtext (original)
+++ mina/site/trunk/content/mina-project/userguide/ch5-filters/ch5.9-logging-filter.mdtext Thu Apr  4 15:44:30 2019
@@ -24,4 +24,60 @@ Notice:    Licensed to the Apache Softwa
 
 # 5.9 - Logging Filter
 
-TBD...
\ No newline at end of file
+The _Logging_ filter allows an application to logs **MINA** protocol events while they are transiting on the filters chain. It can be added dynamically (ie, a session may add a filter whenever it wants).
+
+The tracked events are :
+* _exceptionCaught_
+* _messageReceived_
+* _messageSent_
+* _sessionClosed_
+* _sessionCreated_
+* _sessionIdle_
+* _sessionOpened_
+
+The _event_, _filterClose_, _filterWrite_ and _inputClosed_ events are not tracked.
+
+## Adding the filter
+
+This can be done once and for each session, while creating the _IoFilterChainBuilder_ instance :
+
+    :::Java
+    ...
+    NioSocketAcceptor acceptor = new NioSocketAcceptor();
+    DefaultIoFilterChainBuilder builderChain = acceptor.getFilterChain();
+    builderChain.addLast("logger", new LoggingFilter());
+    ...
+
+or it can be added dynamically, in a given session:
+
+    :::Java
+    ...
+    session.getFilterChain().addLast("logger", new LoggingFilter());
+    ...
+
+(here, the filter is added at the end of the filter's chain, but it can added at the beginning, using _addFirst_, or before or after a given filter, with _addBefore_ or _addAfter_)
+
+## Configuring the filter
+
+Each event can be configured individually. For instance, to log the _messageReceived_ event in _DEBUG_ mode, simply add this code in  your _IoHandler_ implementation:
+
+    :::java
+    ...
+    LoggingFilter loggingFilter = (LoggingFilter)session.getFilterChain().get( LoggingFilter.class );
+
+    if (logginFilter != null) {
+        loggingFilter.setMessageReceivedLogLevel( LogLevel.DEBUG);
+    }
+    ...
+
+This is per session, and it's dynamic.
+
+
+## Removing the filter
+
+It's always possible to remove the filter for a given session :
+
+    ::Java
+    ...
+    session.getFilterChain().remove("logger");
+    ...