incubator-ftpserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n..@apache.org
Subject svn commit: r611408 - in /incubator/ftpserver/trunk/core/src: main/java/org/apache/ftpserver/command/USER.java main/java/org/apache/ftpserver/listener/mina/MinaListener.java test/resources/log4j.properties
Date Sat, 12 Jan 2008 12:56:04 GMT
Author: ngn
Date: Sat Jan 12 04:56:01 2008
New Revision: 611408

URL: http://svn.apache.org/viewvc?rev=611408&view=rev
Log:
Add MDC based logging

Modified:
    incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/USER.java
    incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listener/mina/MinaListener.java
    incubator/ftpserver/trunk/core/src/test/resources/log4j.properties

Modified: incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/USER.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/USER.java?rev=611408&r1=611407&r2=611408&view=diff
==============================================================================
--- incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/USER.java (original)
+++ incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/USER.java Sat
Jan 12 04:56:01 2008
@@ -34,6 +34,7 @@
 import org.apache.ftpserver.usermanager.BaseUser;
 import org.apache.ftpserver.usermanager.ConcurrentLoginRequest;
 import org.apache.ftpserver.util.FtpReplyUtil;
+import org.apache.mina.filter.logging.MdcInjectionFilter;
 
 /**
  * <code>USER &lt;SP&gt; &lt;username&gt; &lt;CRLF&gt;</code><br>
@@ -68,6 +69,9 @@
                 session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS,
"USER", null));
                 return;  
             }
+            
+            // Add to the MDC logging
+            MdcInjectionFilter.setProperty(session, "userName", userName);
             
             // already logged-in
             BaseUser user = (BaseUser)session.getUser();

Modified: incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listener/mina/MinaListener.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listener/mina/MinaListener.java?rev=611408&r1=611407&r2=611408&view=diff
==============================================================================
--- incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listener/mina/MinaListener.java
(original)
+++ incubator/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listener/mina/MinaListener.java
Sat Jan 12 04:56:01 2008
@@ -32,9 +32,11 @@
 import org.apache.ftpserver.ssl.ClientAuth;
 import org.apache.ftpserver.ssl.Ssl;
 import org.apache.mina.common.IdleStatus;
+import org.apache.mina.common.IoSessionLogger;
 import org.apache.mina.filter.codec.ProtocolCodecFilter;
 import org.apache.mina.filter.executor.ExecutorFilter;
 import org.apache.mina.filter.logging.LoggingFilter;
+import org.apache.mina.filter.logging.MdcInjectionFilter;
 import org.apache.mina.filter.ssl.SslFilter;
 import org.apache.mina.transport.socket.SocketAcceptor;
 import org.apache.mina.transport.socket.SocketSessionConfig;
@@ -72,23 +74,23 @@
         }
         
         acceptor.setReuseAddress(true);
+        acceptor.getSessionConfig().setReadBufferSize( 2048 );
+        acceptor.getSessionConfig().setIdleTime( IdleStatus.BOTH_IDLE, 10 );
+        // Decrease the default receiver buffer size
+        ((SocketSessionConfig) acceptor.getSessionConfig()).setReceiveBufferSize(512); 
 
-        acceptor.getFilterChain().addLast("threadPool", new ExecutorFilter(filterExecutor));
+        acceptor.getFilterChain().addLast("mdcFilter", new MdcInjectionFilter());
         acceptor.getFilterChain().addLast(
                 "codec",
                 new ProtocolCodecFilter( new FtpServerProtocolCodecFactory() ) );
+        
+        // dusable the session prefix as we now use MDC logging
+        IoSessionLogger.setUsePrefix(false);
         acceptor.getFilterChain().addLast( "logger", new LoggingFilter() );
-
-        acceptor.setHandler(  new FtpHandler(context, this) );
-
-        acceptor.getSessionConfig().setReadBufferSize( 2048 );
-        acceptor.getSessionConfig().setIdleTime( IdleStatus.BOTH_IDLE, 10 );
+        acceptor.getFilterChain().addLast("threadPool", new ExecutorFilter(filterExecutor));
+        acceptor.getFilterChain().addLast("mdcFilter2", new MdcInjectionFilter());
 
         
-        
-        // Decrease the default receiver buffer size
-        ((SocketSessionConfig) acceptor.getSessionConfig()).setReceiveBufferSize(512); 
-        
         if(isImplicitSsl()) {
             Ssl ssl = getSsl();
             SslFilter sslFilter = new SslFilter( ssl.getSSLContext() );
@@ -105,6 +107,8 @@
             
             acceptor.getFilterChain().addFirst("sslFilter", sslFilter);
         }
+
+        acceptor.setHandler(  new FtpHandler(context, this) );
         
         acceptor.bind(address);
     }

Modified: incubator/ftpserver/trunk/core/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/test/resources/log4j.properties?rev=611408&r1=611407&r2=611408&view=diff
==============================================================================
--- incubator/ftpserver/trunk/core/src/test/resources/log4j.properties (original)
+++ incubator/ftpserver/trunk/core/src/test/resources/log4j.properties Sat Jan 12 04:56:01
2008
@@ -18,5 +18,5 @@
 log4j.rootLogger=DEBUG, C 
 log4j.appender.C=org.apache.log4j.ConsoleAppender 
 log4j.appender.C.layout=org.apache.log4j.PatternLayout 
-log4j.appender.C.layout.ConversionPattern=%m%n
+log4j.appender.C.layout.ConversionPattern=[%X{userName}] %m%n
 



Mime
View raw message