akka.event
Class Logging

java.lang.Object
  extended by akka.event.Logging

public class Logging
extends java.lang.Object

Main entry point for Akka logging: log levels and message types (aka channels) defined for the main transport medium, the main event bus. The recommended use is to obtain an implementation of the Logging trait with suitable and efficient methods for generating log events:


 val log = Logging(<bus>, <source object>)
 ...
 log.info("hello world!")
 

The source object is used in two fashions: its Class[_] will be part of all log events produced by this logger, plus a string representation is generated which may contain per-instance information, see apply or create below.

Loggers are attached to the level-specific channels Error, Warning, Info and Debug as appropriate for the configured (or set) log level. If you want to implement your own, make sure to handle these four event types plus the InitializeLogger message which is sent before actually attaching it to the logging bus.

Logging is configured in akka.conf by setting (some of) the following:


 akka {
   loggers = ["akka.slf4j.Slf4jLogger"] # for example
   loglevel = "INFO"        # used when normal logging ("loggers") has been started
   stdout-loglevel = "WARN" # used during application start-up until normal logging is available
 }
 


Nested Class Summary
static class Logging.Debug
          For DEBUG Logging
static class Logging.Debug$
           
static class Logging.DefaultLogger
          Actor wrapper around the standard output logger.
static class Logging.Error
          For ERROR Logging
static class Logging.Error$
           
static class Logging.Info
          For INFO Logging
static class Logging.Info$
           
static class Logging.InitializeLogger
          Message which is sent to each default logger (i.e. from configuration file) after its creation but before attaching it to the logging bus.
static class Logging.InitializeLogger$
           
static interface Logging.LogEvent
          Base type of LogEvents
static class Logging.LogEventException
          Exception that wraps a LogEvent.
static class Logging.LoggerException
          Artificial exception injected into Error events if no Throwable is supplied; used for getting a stack dump of error locations.
static class Logging.LoggerInitializationException
          LoggerInitializationException is thrown to indicate that there was a problem initializing a logger
static class Logging.LoggerInitialized
          Response message each logger must send within 1 second after receiving the InitializeLogger request.
static class Logging.LoggerInitialized$
           
static class Logging.LogLevel
          Marker trait for annotating LogLevel, which must be Int after erasure.
static class Logging.LogLevel$
           
static class Logging.StandardOutLogger
          Actor-less logging implementation for synchronous logging to standard output.
static interface Logging.StdOutLogger
           
static class Logging.Warning
          For WARNING Logging
static class Logging.Warning$
           
 
Constructor Summary
Logging()
           
 
Method Summary
static scala.collection.immutable.Seq<Logging.LogLevel> AllLogLevels()
           
static
<T> LoggingAdapter
apply(ActorSystem system, T logSource, LogSource<T> evidence$3)
          Obtain LoggingAdapter for the given actor system and source object.
static
<T> LoggingAdapter
apply(LoggingBus bus, T logSource, LogSource<T> evidence$4)
          Obtain LoggingAdapter for the given logging bus and source object.
static java.lang.Class<? extends Logging.LogEvent> classFor(Logging.LogLevel level)
          Returns the event class associated with the given LogLevel
static Logging.LogLevel DebugLevel()
           
static Logging.LogLevel ErrorLevel()
          Log level in numeric form, used when deciding whether a certain log statement should generate a log event.
static LoggingAdapter getLogger(ActorSystem system, java.lang.Object logSource)
          Obtain LoggingAdapter for the given actor system and source object.
static LoggingAdapter getLogger(LoggingBus bus, java.lang.Object logSource)
          Obtain LoggingAdapter for the given logging bus and source object.
static Logging.LogLevel InfoLevel()
           
static Logging.LogLevel levelFor(java.lang.Class<? extends Logging.LogEvent> eventClass)
          Returns the LogLevel associated with the given event class.
static scala.Option<Logging.LogLevel> levelFor(java.lang.String s)
          Returns the LogLevel associated with the given string, valid inputs are upper or lowercase (not mixed) versions of: "error", "warning", "info" and "debug"
static Logging.LoggerInitialized$ loggerInitialized()
          Java API to create a LoggerInitialized message.
static Logging.Error.NoCause$ noCause()
          Null Object used for errors without cause Throwable
static java.lang.String simpleName(java.lang.Class<?> clazz)
          Returns a 'safe' getSimpleName for the provided Class
static java.lang.String simpleName(java.lang.Object obj)
          Returns a 'safe' getSimpleName for the provided object's Class
static java.lang.String stackTraceFor(java.lang.Throwable e)
          Returns the StackTrace for the given Throwable as a String
static Logging.StandardOutLogger StandardOutLogger()
           
static Logging.LogLevel WarningLevel()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Logging

public Logging()
Method Detail

simpleName

public static java.lang.String simpleName(java.lang.Object obj)
Returns a 'safe' getSimpleName for the provided object's Class

Parameters:
obj -
Returns:
the simple name of the given object's Class

simpleName

public static java.lang.String simpleName(java.lang.Class<?> clazz)
Returns a 'safe' getSimpleName for the provided Class

Parameters:
obj -
Returns:
the simple name of the given Class

ErrorLevel

public static final Logging.LogLevel ErrorLevel()
Log level in numeric form, used when deciding whether a certain log statement should generate a log event. Predefined levels are ErrorLevel (1) to DebugLevel (4). In case you want to add more levels, loggers need to be subscribed to their event bus channels manually.


WarningLevel

public static final Logging.LogLevel WarningLevel()

InfoLevel

public static final Logging.LogLevel InfoLevel()

DebugLevel

public static final Logging.LogLevel DebugLevel()

levelFor

public static scala.Option<Logging.LogLevel> levelFor(java.lang.String s)
Returns the LogLevel associated with the given string, valid inputs are upper or lowercase (not mixed) versions of: "error", "warning", "info" and "debug"


levelFor

public static Logging.LogLevel levelFor(java.lang.Class<? extends Logging.LogEvent> eventClass)
Returns the LogLevel associated with the given event class. Defaults to DebugLevel.


classFor

public static java.lang.Class<? extends Logging.LogEvent> classFor(Logging.LogLevel level)
Returns the event class associated with the given LogLevel


AllLogLevels

public static scala.collection.immutable.Seq<Logging.LogLevel> AllLogLevels()

apply

public static <T> LoggingAdapter apply(ActorSystem system,
                                       T logSource,
                                       LogSource<T> evidence$3)
Obtain LoggingAdapter for the given actor system and source object. This will use the system’s event stream and include the system’s address in the log source string.

Do not use this if you want to supply a log category string (like “com.example.app.whatever”) unaltered, supply system.eventStream in this case or use


 Logging(system, this.getClass)
 

The source is used to identify the source of this logging channel and must have a corresponding implicit LogSource[T] instance in scope; by default these are provided for Class[_], Actor, ActorRef and String types. See the companion object of LogSource for details.

You can add your own rules quite easily, see LogSource.


apply

public static <T> LoggingAdapter apply(LoggingBus bus,
                                       T logSource,
                                       LogSource<T> evidence$4)
Obtain LoggingAdapter for the given logging bus and source object.

The source is used to identify the source of this logging channel and must have a corresponding implicit LogSource[T] instance in scope; by default these are provided for Class[_], Actor, ActorRef and String types. See the companion object of LogSource for details.

You can add your own rules quite easily, see LogSource.


getLogger

public static LoggingAdapter getLogger(ActorSystem system,
                                       java.lang.Object logSource)
Obtain LoggingAdapter for the given actor system and source object. This will use the system’s event stream and include the system’s address in the log source string.

Do not use this if you want to supply a log category string (like “com.example.app.whatever”) unaltered, supply system.eventStream in this case or use


 Logging.getLogger(system, this.getClass());
 

The source is used to identify the source of this logging channel and must have a corresponding implicit LogSource[T] instance in scope; by default these are provided for Class[_], Actor, ActorRef and String types. See the companion object of LogSource for details.


getLogger

public static LoggingAdapter getLogger(LoggingBus bus,
                                       java.lang.Object logSource)
Obtain LoggingAdapter for the given logging bus and source object.

The source is used to identify the source of this logging channel and must have a corresponding implicit LogSource[T] instance in scope; by default these are provided for Class[_], Actor, ActorRef and String types. See the companion object of LogSource for details.


noCause

public static Logging.Error.NoCause$ noCause()
Null Object used for errors without cause Throwable


loggerInitialized

public static Logging.LoggerInitialized$ loggerInitialized()
Java API to create a LoggerInitialized message.


StandardOutLogger

public static Logging.StandardOutLogger StandardOutLogger()

stackTraceFor

public static java.lang.String stackTraceFor(java.lang.Throwable e)
Returns the StackTrace for the given Throwable as a String