diff --git a/akka-actors/src/main/scala/actor/Actor.scala b/akka-actors/src/main/scala/actor/Actor.scala index ea2c64d880..6fa50ea106 100644 --- a/akka-actors/src/main/scala/actor/Actor.scala +++ b/akka-actors/src/main/scala/actor/Actor.scala @@ -738,7 +738,7 @@ trait Actor extends Logging with TransactionManagement { else dispatch(messageHandle) } catch { case e => - log.error(e, e.getMessage) // for logging the exception to log file + log.error(e, "Could not invoke actor [%s]", this) throw e } } @@ -755,7 +755,7 @@ trait Actor extends Logging with TransactionManagement { else throw new IllegalArgumentException("No handler matching message [" + message + "] in " + toString) } catch { case e => - log.error(e, e.getMessage) + log.error(e, "Could not invoke actor [%s]", this) // FIXME to fix supervisor restart of remote actor for oneway calls, inject a supervisor proxy that can send notification back to client if (_supervisor.isDefined) _supervisor.get ! Exit(this, e) if (senderFuture.isDefined) senderFuture.get.completeWithException(this, e) @@ -795,7 +795,7 @@ trait Actor extends Logging with TransactionManagement { } else proceed } catch { case e => - log.error(e, e.getMessage) + log.error(e, "Could not invoke actor [%s]", this) if (senderFuture.isDefined) senderFuture.get.completeWithException(this, e) clearTransaction // need to clear currentTransaction before call to supervisor // FIXME to fix supervisor restart of remote actor for oneway calls, inject a supervisor proxy that can send notification back to client diff --git a/akka-amqp/src/main/scala/AMQP.scala b/akka-amqp/src/main/scala/AMQP.scala index af56bfc8a1..462e65f854 100644 --- a/akka-amqp/src/main/scala/AMQP.scala +++ b/akka-amqp/src/main/scala/AMQP.scala @@ -366,7 +366,7 @@ object AMQP { reconnect(delay) case Failure(cause) => - log.error(cause, "") + log.error(cause, "Error in AMQP consumer") throw cause case Stop => @@ -421,8 +421,8 @@ object AMQP { } catch { case cause => log.error( - "Delivery of message to MessageConsumerListener [%s] failed due to [%s]", - listener.toString(exchangeName), cause.toString) + cause, "Delivery of message to MessageConsumerListener [%s] failed", + listener.toString(exchangeName)) consumer ! Failure(cause) // pass on and re-throw exception in consumer actor to trigger restart and reconnect } } diff --git a/akka-kernel/src/main/scala/Kernel.scala b/akka-kernel/src/main/scala/Kernel.scala index e4f66a9050..7e988d1ede 100644 --- a/akka-kernel/src/main/scala/Kernel.scala +++ b/akka-kernel/src/main/scala/Kernel.scala @@ -94,7 +94,7 @@ object Kernel extends Logging { val DEPLOY = HOME.get + "/deploy" val DEPLOY_DIR = new File(DEPLOY) if (!DEPLOY_DIR.exists) { - log.error("Could not find a deploy directory at [" + DEPLOY + "]") + log.error("Could not find a deploy directory at [%s]", DEPLOY) System.exit(-1) } val toDeploy = for (f <- DEPLOY_DIR.listFiles().toArray.toList.asInstanceOf[List[File]]) yield f.toURL diff --git a/akka-security/src/main/scala/Security.scala b/akka-security/src/main/scala/Security.scala index 6efa5bdcce..f6f2b939a1 100644 --- a/akka-security/src/main/scala/Security.scala +++ b/akka-security/src/main/scala/Security.scala @@ -91,7 +91,7 @@ class AkkaSecurityFilterFactory extends ResourceFilterFactory with Logging { case r if r.isInstanceOf[Response] => throw new WebApplicationException(r.asInstanceOf[Response]) case x => { - log.error("Authenticator replied with unexpected result: ", x); + log.error("Authenticator replied with unexpected result [%s]", x); throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR) } } @@ -100,7 +100,9 @@ class AkkaSecurityFilterFactory extends ResourceFilterFactory with Logging { } } - lazy val authenticatorFQN = Config.config.getString("akka.rest.authenticator").getOrElse(throw new IllegalStateException("akka.rest.authenticator")) + lazy val authenticatorFQN = + Config.config.getString("akka.rest.authenticator") + .getOrElse(throw new IllegalStateException("akka.rest.authenticator")) /** * Currently we always take the first, since there usually should be at most one authentication actor, but a round-robin diff --git a/akka-util/src/main/scala/Logging.scala b/akka-util/src/main/scala/Logging.scala index 39f2afee21..feb088ac2b 100644 --- a/akka-util/src/main/scala/Logging.scala +++ b/akka-util/src/main/scala/Logging.scala @@ -4,11 +4,8 @@ package se.scalablesolutions.akka.util -import java.util.logging.Level -import net.lag.configgy.Config import net.lag.logging.Logger -import java.util.Date import java.io.StringWriter; import java.io.PrintWriter; import java.net.InetAddress; @@ -16,15 +13,11 @@ import java.net.UnknownHostException; /** * Base trait for all classes that wants to be able use the logging infrastructure. - * + * * @author Jonas Bonér */ trait Logging { - @transient var log = { - val log = Logger.get(this.getClass.getName) - //0log.setLevel(Level.ALL) - log - } + @transient @volatile var log = Logger.get(this.getClass.getName) } /** @@ -34,7 +27,7 @@ trait Logging { * It keeps track of the exception is logged or not and also stores the unique id, * so that it can be carried all along to the client tier and displayed to the end user. * The end user can call up the customer support using this number. - * + * * @author Jonas Bonér */ class LoggableException extends Exception with Logging { @@ -50,14 +43,14 @@ class LoggableException extends Exception with Logging { def logException = synchronized { if (!isLogged) { originalException match { - case Some(e) => log.error("Logged Exception [%s] %s", uniqueId, getStackTrace(e)) - case None => log.error("Logged Exception [%s] %s", uniqueId, getStackTrace(this)) + case Some(e) => log.error("Logged Exception [%s] %s", uniqueId, getStackTraceAsString(e)) + case None => log.error("Logged Exception [%s] %s", uniqueId, getStackTraceAsString(this)) } isLogged = true } - } + } - def getExceptionID: String = { + private def getExceptionID: String = { val hostname: String = try { InetAddress.getLocalHost.getHostName } catch { @@ -68,7 +61,7 @@ class LoggableException extends Exception with Logging { hostname + "_" + System.currentTimeMillis } - def getStackTrace(exception: Throwable): String = { + private def getStackTraceAsString(exception: Throwable): String = { val sw = new StringWriter val pw = new PrintWriter(sw) exception.printStackTrace(pw)