object Logging
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:
pekko {
loggers = ["org.apache.pekko.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
}
- Source
- Logging.scala
- Alphabetic
- By Inheritance
- Logging
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- case class Debug(logSource: String, logClass: Class[_], message: Any = "") extends LogEvent with Product with Serializable
For DEBUG Logging
- class Debug2 extends Debug
- class Debug3 extends Debug2 with LogEventWithMarker
- class DefaultLogger extends Actor with StdOutLogger with RequiresMessageQueue[LoggerMessageQueueSemantics]
Actor wrapper around the standard output logger.
Actor wrapper around the standard output logger. If
pekko.loggers
is not set, it defaults to just this logger. - case class Error(cause: Throwable, logSource: String, logClass: Class[_], message: Any = "") extends LogEvent with LogEventWithCause with Product with Serializable
For ERROR Logging
- class Error2 extends Error
- class Error3 extends Error2 with LogEventWithMarker
- case class Info(logSource: String, logClass: Class[_], message: Any = "") extends LogEvent with Product with Serializable
For INFO Logging
- class Info2 extends Info
- class Info3 extends Info2 with LogEventWithMarker
- final case class InitializeLogger(bus: LoggingBus) extends NoSerializationVerificationNeeded with Product with Serializable
Message which is sent to each default logger (i.e.
Message which is sent to each default logger (i.e. from configuration file) after its creation but before attaching it to the logging bus. The logger actor must handle this message, it can be used e.g. to register for more channels. When done, the logger must respond with a LoggerInitialized message. This is necessary to ensure that additional subscriptions are in effect when the logging system finished starting.
- sealed trait LogEvent extends NoSerializationVerificationNeeded
Base type of LogEvents
- class LogEventException extends Throwable with NoStackTrace
Exception that wraps a LogEvent.
- trait LogEventWithCause extends AnyRef
- sealed trait LogEventWithMarker extends LogEvent
INTERNAL API, Marker interface for LogEvents containing Markers, which can be set for example on an slf4j logger
- final case class LogLevel(asInt: Int) extends AnyVal with Product with Serializable
Marker trait for annotating LogLevel, which must be Int after erasure.
- class LoggerException extends PekkoException
Artificial exception injected into Error events if no Throwable is supplied; used for getting a stack dump of error locations.
- class LoggerInitializationException extends PekkoException
LoggerInitializationException is thrown to indicate that there was a problem initializing a logger
- abstract class LoggerInitialized extends AnyRef
Response message each logger must send within 1 second after receiving the InitializeLogger request.
Response message each logger must send within 1 second after receiving the InitializeLogger request. If initialization takes longer, send the reply as soon as subscriptions are set-up.
- type MDC = Map[String, Any]
- class StandardOutLogger extends InternalActorRef with MinimalActorRef with StdOutLogger
Actor-less logging implementation for synchronous logging to standard output.
Actor-less logging implementation for synchronous logging to standard output. This logger is always attached first in order to be able to log failures during application start-up, even before normal logging is started. Its log level can be defined by configuration setting
pekko.stdout-loglevel
. - trait StdOutLogger extends AnyRef
- case class Warning(logSource: String, logClass: Class[_], message: Any = "") extends LogEvent with Product with Serializable
For WARNING Logging
- class Warning2 extends Warning
- class Warning3 extends Warning2 with LogEventWithMarker
- class Warning4 extends Warning2 with LogEventWithMarker with LogEventWithCause
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- val AllLogLevels: Seq[LogLevel]
- final val DebugLevel: LogLevel
- final val ErrorLevel: LogLevel
Log level in numeric form, used when deciding whether a certain log statement should generate a log event.
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.
- final val InfoLevel: LogLevel
- val StandardOutLogger: StandardOutLogger
- final val WarningLevel: LogLevel
- def apply(logSource: Actor): DiagnosticLoggingAdapter
Obtain LoggingAdapter with MDC support for the given actor.
Obtain LoggingAdapter with MDC support for the given actor. Don't use it outside its specific Actor as it isn't thread safe
- def apply[T](bus: LoggingBus, logSource: T)(implicit arg0: LogSource[T]): LoggingAdapter
Obtain LoggingAdapter for the given logging bus and source object.
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 pekko.event.LogSource for details.
You can add your own rules quite easily, see pekko.event.LogSource.
Note that this
LoggingAdapter
will use the pekko.event.DefaultLoggingFilter, and not the pekko.event.LoggingFilter configured for the system (if different fromDefaultLoggingFilter
). - def apply[T](system: ActorSystem, logSource: T)(implicit arg0: LogSource[T]): LoggingAdapter
Obtain LoggingAdapter for the given actor system and source object.
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 useLogging(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 pekko.event.LogSource for details.
You can add your own rules quite easily, see pekko.event.LogSource.
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def classFor(level: LogLevel): Class[_ <: LogEvent]
Returns the event class associated with the given LogLevel
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @HotSpotIntrinsicCandidate() @native()
- val emptyMDC: MDC
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- def getLogger(logSource: Actor): DiagnosticLoggingAdapter
Obtain LoggingAdapter with MDC support for the given actor.
Obtain LoggingAdapter with MDC support for the given actor. Don't use it outside its specific Actor as it isn't thread safe
- def getLogger(bus: LoggingBus, logSource: AnyRef): LoggingAdapter
Obtain LoggingAdapter for the given logging bus and source object.
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 pekko.event.LogSource for details.
Note that this
LoggingAdapter
will use the pekko.event.DefaultLoggingFilter, and not the pekko.event.LoggingFilter configured for the system (if different fromDefaultLoggingFilter
). - def getLogger(system: ActorSystem, logSource: AnyRef): LoggingAdapter
Obtain LoggingAdapter for the given actor system and source object.
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 useLogging.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 pekko.event.LogSource for details.
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def levelFor(eventClass: Class[_ <: LogEvent]): LogLevel
Returns the LogLevel associated with the given event class.
Returns the LogLevel associated with the given event class. Defaults to DebugLevel.
- def levelFor(s: String): Option[LogLevel]
Returns the LogLevel associated with the given string, valid inputs are upper or lowercase (not mixed) versions of: "error", "warning", "info" and "debug"
- def loggerInitialized(): LoggerInitialized.type
Java API to create a LoggerInitialized message.
- def messageClassName(message: Any): String
Class name representation of a message.
Class name representation of a message.
ActorSelectionMessage
representation includes class name of wrapped message. - final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def noCause: NoCause
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- def simpleName(clazz: Class[_]): String
Returns a 'safe' getSimpleName for the provided Class
Returns a 'safe' getSimpleName for the provided Class
- returns
the simple name of the given Class
- def simpleName(obj: AnyRef): String
Returns a 'safe' getSimpleName for the provided object's Class
Returns a 'safe' getSimpleName for the provided object's Class
- returns
the simple name of the given object's Class
- def stackTraceFor(e: Throwable): String
Returns the StackTrace for the given Throwable as a String
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- def withMarker(logSource: Actor): DiagnosticMarkerBusLoggingAdapter
Obtain LoggingAdapter with marker and MDC support for the given actor.
Obtain LoggingAdapter with marker and MDC support for the given actor. Don't use it outside its specific Actor as it isn't thread safe
- def withMarker[T](bus: LoggingBus, logSource: T)(implicit arg0: LogSource[T]): MarkerLoggingAdapter
Obtain LoggingAdapter for the given logging bus and source object.
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 pekko.event.LogSource for details.
You can add your own rules quite easily, see pekko.event.LogSource.
Note that this
LoggingAdapter
will use the pekko.event.DefaultLoggingFilter, and not the pekko.event.LoggingFilter configured for the system (if different fromDefaultLoggingFilter
). - def withMarker[T](system: ActorSystem, logSource: T)(implicit arg0: LogSource[T]): MarkerLoggingAdapter
Obtain LoggingAdapter with additional "marker" support (which some logging frameworks are able to utilise) for the given actor system and source object.
Obtain LoggingAdapter with additional "marker" support (which some logging frameworks are able to utilise) 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 useLogging(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 pekko.event.LogSource for details.
You can add your own rules quite easily, see pekko.event.LogSource.
- object Debug extends Serializable
- object Error extends Serializable
- object Info extends Serializable
- object LogEvent
- case object LoggerInitialized extends LoggerInitialized with Product with Serializable
- object StdOutLogger
- object Warning extends Serializable