You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ch...@apache.org on 2011/08/25 18:08:12 UTC

svn commit: r1161621 - in /activemq/activemq-apollo/trunk: apollo-cli/src/main/resources/org/apache/activemq/apollo/cli/commands/etc/log4j.properties apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompProtocolHandler.scala

Author: chirino
Date: Thu Aug 25 16:08:11 2011
New Revision: 1161621

URL: http://svn.apache.org/viewvc?rev=1161621&view=rev
Log:
Fixes https://issues.apache.org/jira/browse/APLO-79 : Connection errors are now logged to the connection.log

Modified:
    activemq/activemq-apollo/trunk/apollo-cli/src/main/resources/org/apache/activemq/apollo/cli/commands/etc/log4j.properties
    activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompProtocolHandler.scala

Modified: activemq/activemq-apollo/trunk/apollo-cli/src/main/resources/org/apache/activemq/apollo/cli/commands/etc/log4j.properties
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-cli/src/main/resources/org/apache/activemq/apollo/cli/commands/etc/log4j.properties?rev=1161621&r1=1161620&r2=1161621&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-cli/src/main/resources/org/apache/activemq/apollo/cli/commands/etc/log4j.properties (original)
+++ activemq/activemq-apollo/trunk/apollo-cli/src/main/resources/org/apache/activemq/apollo/cli/commands/etc/log4j.properties Thu Aug 25 16:08:11 2011
@@ -18,9 +18,12 @@
 #
 # Setup the default logging levels
 #
-log4j.rootLogger=WARN, console, apollo
+#
+# Setup the default logging levels
+#
+log4j.rootLogger=WARN, console-warn, apollo
 
-log4j.logger.console=INFO, console, apollo
+log4j.logger.console=INFO, console-info, apollo
 log4j.additivity.console=false
 log4j.logger.security=INFO, security
 log4j.additivity.security=false
@@ -39,10 +42,14 @@ log4j.logger.org.apache.activemq.apollo=
 # log4j.logger.org.apache.activemq.apollo.cli=DEBUG
 
 # Console Settings
-log4j.appender.console=org.apache.log4j.ConsoleAppender
-log4j.appender.console.layout=org.apache.log4j.PatternLayout
-log4j.appender.console.layout.ConversionPattern=%-5p | %m%n
-log4j.appender.console.threshold=INFO
+log4j.appender.console-info=org.apache.log4j.ConsoleAppender
+log4j.appender.console-info.layout=org.apache.log4j.PatternLayout
+log4j.appender.console-info.layout.ConversionPattern=%-5p | %m%n
+log4j.appender.console-info.threshold=INFO
+log4j.appender.console-warn=org.apache.log4j.ConsoleAppender
+log4j.appender.console-warn.layout=org.apache.log4j.PatternLayout
+log4j.appender.console-warn.layout.ConversionPattern=%-5p | %m%n
+log4j.appender.console-warn.threshold=WARN
 
 # File Settings
 log4j.appender.apollo=org.apache.log4j.RollingFileAppender

Modified: activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompProtocolHandler.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompProtocolHandler.scala?rev=1161621&r1=1161620&r2=1161621&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompProtocolHandler.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompProtocolHandler.scala Thu Aug 25 16:08:11 2011
@@ -82,6 +82,7 @@ object StompProtocolHandler extends Log 
 class StompProtocolHandler extends ProtocolHandler {
   import StompProtocolHandler._
 
+  var connection_log:Log = StompProtocolHandler
   def protocol = "stomp"
 
   def decode_header(value:Buffer):String = {
@@ -556,9 +557,9 @@ class StompProtocolHandler extends Proto
 
   private def die[T](msg:String, e:Throwable=null):T = {
     if( e!=null) {
-      debug(e, "Shutting connection down due to: "+msg)
+      connection_log.info(e, "STOMP connection '%s' error: %s", security_context.remote_address, msg)
     } else {
-      debug("Shutting connection down due to: "+msg)
+      connection_log.info("STOMP connection '%s' error: %s", security_context.remote_address, msg)
     }
     die((MESSAGE_HEADER, encode_header(msg))::Nil, "")
   }
@@ -585,6 +586,7 @@ class StompProtocolHandler extends Proto
   }
 
   override def on_transport_connected() = {
+    connection_log = connection.connector.broker.connection_log
     sink_manager = new SinkMux[StompFrame]( connection.transport_sink.map {x=>
       trace("sending frame: %s", x)
       x
@@ -683,13 +685,11 @@ class StompProtocolHandler extends Proto
           }
 
         case _=>
-          warn("Internal Server Error: unexpected command type")
-          die("Internal Server Error");
+          die("Internal Server Error: unexpected command type");
       }
     }  catch {
       case e: Break =>
       case e:Exception =>
-        e.printStackTrace
         async_die("Internal Server Error", e);
     }
   }
@@ -815,13 +815,25 @@ class StompProtocolHandler extends Proto
         noop
       } else {
         this.host=host
+        connection_log = host.connection_log
         if( host.authenticator!=null &&  host.authorizer!=null ) {
           suspendRead("authenticating and authorizing connect")
           if( !host.authenticator.authenticate(security_context) ) {
-            async_die("Authentication failed.")
+            var msg = if( security_context.user==null ) {
+              "Authentication failed."
+            } else {
+              "Authentication failed. Username: "+security_context.user
+            }
+            async_die(msg)
             noop // to make the cps compiler plugin happy.
           } else if( !host.authorizer.can_connect_to(security_context, host, connection.connector) ) {
-            async_die("Connect not authorized.")
+
+            var msg = if( security_context.user==null ) {
+              "Connect not authorized."
+            } else {
+              "Connect not authorized. Username: "+security_context.user
+            }
+            async_die(msg)
             noop // to make the cps compiler plugin happy.
           } else {
             resumeRead
@@ -1201,7 +1213,7 @@ class StompProtocolHandler extends Proto
   override def on_transport_failure(error: IOException) = {
     if( !connection.stopped ) {
       suspendRead("shutdown")
-      debug(error, "Shutting connection down due to: %s", error)
+      connection_log.debug(error, "Shutting connection '%s'  down due to: %s", security_context.remote_address, error)
       super.on_transport_failure(error);
     }
   }