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 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
 }
 


Field Summary
static Logging$ MODULE$
          Static reference to the singleton instance of this Scala object.
 
Constructor Summary
Logging$()
           
 
Method Summary
 scala.collection.immutable.Seq<Logging.LogLevel> AllLogLevels()
           
 DiagnosticLoggingAdapter apply(Actor logSource)
          Obtain LoggingAdapter with MDC support for the given actor.
<T> LoggingAdapter
apply(ActorSystem system, T logSource, LogSource<T> evidence$3)
          Obtain LoggingAdapter for the given actor system and source object.
<T> LoggingAdapter
apply(LoggingBus bus, T logSource, LogSource<T> evidence$4)
          Obtain LoggingAdapter for the given logging bus and source object.
 java.lang.Class<? extends Logging.LogEvent> classFor(Logging.LogLevel level)
          Returns the event class associated with the given LogLevel
 Logging.LogLevel DebugLevel()
           
 scala.collection.immutable.Map<java.lang.String,java.lang.Object> emptyMDC()
           
 Logging.LogLevel ErrorLevel()
          Log level in numeric form, used when deciding whether a certain log statement should generate a log event.
 LoggingAdapter getLogger(ActorSystem system, java.lang.Object logSource)
          Obtain LoggingAdapter for the given actor system and source object.
 LoggingAdapter getLogger(LoggingBus bus, java.lang.Object logSource)
          Obtain LoggingAdapter for the given logging bus and source object.
 DiagnosticLoggingAdapter getLogger(UntypedActor logSource)
          Obtain LoggingAdapter with MDC support for the given actor.
 Logging.LogLevel InfoLevel()
           
 Logging.LogLevel levelFor(java.lang.Class<? extends Logging.LogEvent> eventClass)
          Returns the LogLevel associated with the given event class.
 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"
 Logging.LoggerInitialized$ loggerInitialized()
          Java API to create a LoggerInitialized message.
 Logging.Error.NoCause$ noCause()
           
 java.lang.String simpleName(java.lang.Class<?> clazz)
          Returns a 'safe' getSimpleName for the provided Class
 java.lang.String simpleName(java.lang.Object obj)
          Returns a 'safe' getSimpleName for the provided object's Class
 java.lang.String stackTraceFor(java.lang.Throwable e)
          Returns the StackTrace for the given Throwable as a String
 Logging.StandardOutLogger StandardOutLogger()
           
 Logging.LogLevel WarningLevel()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MODULE$

public static final Logging$ MODULE$
Static reference to the singleton instance of this Scala object.

Constructor Detail

Logging$

public Logging$()
Method Detail

simpleName

public 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 java.lang.String simpleName(java.lang.Class<?> clazz)
Returns a 'safe' getSimpleName for the provided Class

Parameters:
obj -
clazz - (undocumented)
Returns:
the simple name of the given Class

ErrorLevel

public 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.

Returns:
(undocumented)

WarningLevel

public final Logging.LogLevel WarningLevel()

InfoLevel

public final Logging.LogLevel InfoLevel()

DebugLevel

public final Logging.LogLevel DebugLevel()

levelFor

public 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"

Parameters:
s - (undocumented)
Returns:
(undocumented)

levelFor

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

Parameters:
eventClass - (undocumented)
Returns:
(undocumented)

classFor

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

Parameters:
level - (undocumented)
Returns:
(undocumented)

AllLogLevels

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

apply

public <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&rsquo;s event stream and include the system&rsquo;s address in the log source string.

Do not use this if you want to supply a log category string (like &ldquo;com.example.app.whatever&rdquo;) 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.

Parameters:
system - (undocumented)
logSource - (undocumented)
evidence$3 - (undocumented)
Returns:
(undocumented)

apply

public <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.

Parameters:
bus - (undocumented)
logSource - (undocumented)
evidence$4 - (undocumented)
Returns:
(undocumented)

apply

public DiagnosticLoggingAdapter apply(Actor logSource)
Obtain LoggingAdapter with MDC support for the given actor. Don't use it outside its specific Actor as it isn't thread safe

Parameters:
logSource - (undocumented)
Returns:
(undocumented)

getLogger

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

Do not use this if you want to supply a log category string (like &ldquo;com.example.app.whatever&rdquo;) 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.

Parameters:
system - (undocumented)
logSource - (undocumented)
Returns:
(undocumented)

getLogger

public 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.

Parameters:
bus - (undocumented)
logSource - (undocumented)
Returns:
(undocumented)

getLogger

public DiagnosticLoggingAdapter getLogger(UntypedActor logSource)
Obtain LoggingAdapter with MDC support for the given actor. Don't use it outside its specific Actor as it isn't thread safe

Parameters:
logSource - (undocumented)
Returns:
(undocumented)

noCause

public Logging.Error.NoCause$ noCause()

loggerInitialized

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

Returns:
(undocumented)

StandardOutLogger

public Logging.StandardOutLogger StandardOutLogger()

stackTraceFor

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

Parameters:
e - (undocumented)
Returns:
(undocumented)

emptyMDC

public scala.collection.immutable.Map<java.lang.String,java.lang.Object> emptyMDC()