+act,slf #11715 Add configurable LoggingFilter
* The filter is used by the LoggingAdapter before publishing to the event bus * Slf4jLoggingFilter uses backend log level configuration (e.g. logback.xml)
This commit is contained in:
parent
51062ff494
commit
813543e8f8
13 changed files with 285 additions and 46 deletions
|
|
@ -147,6 +147,10 @@ A custom ``application.conf`` might look like this::
|
|||
# This logger prints the log messages to stdout (System.out).
|
||||
# Options: OFF, ERROR, WARNING, INFO, DEBUG
|
||||
stdout-loglevel = "DEBUG"
|
||||
|
||||
# Filter of log events that is used by the LoggingAdapter before
|
||||
# publishing log events to the eventStream.
|
||||
logging-filter = "akka.event.slf4j.Slf4jLoggingFilter"
|
||||
|
||||
actor {
|
||||
provider = "akka.cluster.ClusterActorRefProvider"
|
||||
|
|
|
|||
|
|
@ -222,7 +222,9 @@ and it will receive the log events in the same order as they were emitted.
|
|||
|
||||
You can configure which event handlers are created at system start-up and listen to logging events. That is done using the
|
||||
``loggers`` element in the :ref:`configuration`.
|
||||
Here you can also define the log level.
|
||||
Here you can also define the log level. More fine grained filtering based on the log source
|
||||
can be implemented in a custom ``LoggingFilter``, which can be defined in the ``logging-filter``
|
||||
configuration property.
|
||||
|
||||
.. code-block:: ruby
|
||||
|
||||
|
|
@ -245,8 +247,6 @@ Example of creating a listener:
|
|||
.. includecode:: code/docs/event/LoggingDocTest.java
|
||||
:include: my-event-listener
|
||||
|
||||
.. _slf4j-java:
|
||||
|
||||
Logging to stdout during startup and shutdown
|
||||
=============================================
|
||||
|
||||
|
|
@ -255,6 +255,8 @@ Instead log messages are printed to stdout (System.out). The default log level f
|
|||
stdout logger is ``WARNING`` and it can be silenced completely by setting
|
||||
``akka.stdout-loglevel=OFF``.
|
||||
|
||||
.. _slf4j-java:
|
||||
|
||||
SLF4J
|
||||
=====
|
||||
|
||||
|
|
@ -269,16 +271,19 @@ It has one single dependency; the slf4j-api jar. In runtime you also need a SLF4
|
|||
<version>1.0.13</version>
|
||||
</dependency>
|
||||
|
||||
You need to enable the Slf4jLogger in the 'loggers' element in
|
||||
You need to enable the Slf4jLogger in the ``loggers`` element in
|
||||
the :ref:`configuration`. Here you can also define the log level of the event bus.
|
||||
More fine grained log levels can be defined in the configuration of the SLF4J backend
|
||||
(e.g. logback.xml).
|
||||
(e.g. logback.xml). You should also define ``akka.event.slf4j.Slf4jLoggingFilter`` in
|
||||
the ``logging-filter`` configuration property. It will filter the log events using the backend
|
||||
configuration (e.g. logback.xml) before they are published to the event bus.
|
||||
|
||||
.. code-block:: ruby
|
||||
|
||||
akka {
|
||||
loggers = ["akka.event.slf4j.Slf4jLogger"]
|
||||
loglevel = "DEBUG"
|
||||
logging-filter = "akka.event.slf4j.Slf4jLoggingFilter"
|
||||
}
|
||||
|
||||
One gotcha is that the timestamp is attributed in the event handler, not when actually doing the logging.
|
||||
|
|
|
|||
|
|
@ -94,3 +94,12 @@ The following, previously deprecated, features have been removed:
|
|||
|
||||
* Java API TestKit.dilated, moved to JavaTestKit.dilated
|
||||
|
||||
Slf4j logging filter
|
||||
====================
|
||||
|
||||
If you use ``Slf4jLogger`` you should add the following configuration::
|
||||
|
||||
akka.logging-filter = "akka.event.slf4j.Slf4jLoggingFilter"
|
||||
|
||||
It will filter the log events using the backend configuration (e.g. logback.xml) before
|
||||
they are published to the event bus.
|
||||
|
|
|
|||
|
|
@ -263,7 +263,9 @@ and it will receive the log events in the same order as they were emitted.
|
|||
|
||||
You can configure which event handlers are created at system start-up and listen to logging events. That is done using the
|
||||
``loggers`` element in the :ref:`configuration`.
|
||||
Here you can also define the log level.
|
||||
Here you can also define the log level. More fine grained filtering based on the log source
|
||||
can be implemented in a custom ``LoggingFilter``, which can be defined in the ``logging-filter``
|
||||
configuration property.
|
||||
|
||||
.. code-block:: ruby
|
||||
|
||||
|
|
@ -284,8 +286,6 @@ Example of creating a listener:
|
|||
.. includecode:: code/docs/event/LoggingDocSpec.scala
|
||||
:include: my-event-listener
|
||||
|
||||
.. _slf4j-scala:
|
||||
|
||||
Logging to stdout during startup and shutdown
|
||||
=============================================
|
||||
|
||||
|
|
@ -294,6 +294,8 @@ Instead log messages are printed to stdout (System.out). The default log level f
|
|||
stdout logger is ``WARNING`` and it can be silenced completely by setting
|
||||
``akka.stdout-loglevel=OFF``.
|
||||
|
||||
.. _slf4j-scala:
|
||||
|
||||
SLF4J
|
||||
=====
|
||||
|
||||
|
|
@ -302,19 +304,22 @@ It has one single dependency; the slf4j-api jar. In runtime you also need a SLF4
|
|||
|
||||
.. code-block:: scala
|
||||
|
||||
lazy val logback = "ch.qos.logback" % "logback-classic" % "1.0.13"
|
||||
libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.0.13"
|
||||
|
||||
|
||||
You need to enable the Slf4jLogger in the 'loggers' element in
|
||||
You need to enable the Slf4jLogger in the ``loggers`` element in
|
||||
the :ref:`configuration`. Here you can also define the log level of the event bus.
|
||||
More fine grained log levels can be defined in the configuration of the SLF4J backend
|
||||
(e.g. logback.xml).
|
||||
(e.g. logback.xml). You should also define ``akka.event.slf4j.Slf4jLoggingFilter`` in
|
||||
the ``logging-filter`` configuration property. It will filter the log events using the backend
|
||||
configuration (e.g. logback.xml) before they are published to the event bus.
|
||||
|
||||
.. code-block:: ruby
|
||||
|
||||
akka {
|
||||
loggers = ["akka.event.slf4j.Slf4jLogger"]
|
||||
loglevel = "DEBUG"
|
||||
logging-filter = "akka.event.slf4j.Slf4jLoggingFilter"
|
||||
}
|
||||
|
||||
One gotcha is that the timestamp is attributed in the event handler, not when actually doing the logging.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue