From b57c9e8f5e08686375f9ff6c26af9340ec30ee5f Mon Sep 17 00:00:00 2001 From: Roland Date: Fri, 3 Feb 2012 10:47:56 +0100 Subject: [PATCH 1/3] update docs for SLF4J, see #1779 --- akka-docs/java/logging.rst | 20 ++++++++++++++++++-- akka-docs/scala/logging.rst | 20 ++++++++++++++++++-- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/akka-docs/java/logging.rst b/akka-docs/java/logging.rst index 7166108306..7ac04ca657 100644 --- a/akka-docs/java/logging.rst +++ b/akka-docs/java/logging.rst @@ -184,8 +184,7 @@ It has one single dependency; the slf4j-api jar. In runtime you also need a SLF4 You need to enable the Slf4jEventHandler in the 'event-handlers' 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). The String representation of the source object that is used when -creating the ``LoggingAdapter`` correspond to the name of the SL4FJ logger. +(e.g. logback.xml). .. code-block:: ruby @@ -194,6 +193,23 @@ creating the ``LoggingAdapter`` correspond to the name of the SL4FJ logger. loglevel = "DEBUG" } +The SLF4J logger selected for each log event is chosen based on the +:class:`Class[_]` of the log source specified when creating the +:class:`LoggingAdapter`, unless that was given directly as a string in which +case that string is used (i.e. ``LoggerFactory.getLogger(Class c)`` is used in +the first case and ``LoggerFactory.getLogger(String s)`` in the second). + +.. note:: + + Beware that the the actor system’s name is appended to a :class:`String` log + source if the LoggingAdapter was created giving an :class:`ActorSystem` to + the factory. If this is not intended, give a :class:`LoggingBus` instead as + shown below: + +.. code-block:: scala + + final LoggingAdapter log = Logging.getLogger(system.eventStream, "my.nice.string"); + Logging Thread and Akka Source in MDC ------------------------------------- diff --git a/akka-docs/scala/logging.rst b/akka-docs/scala/logging.rst index 908017e8b8..dc87126c5b 100644 --- a/akka-docs/scala/logging.rst +++ b/akka-docs/scala/logging.rst @@ -217,8 +217,7 @@ It has one single dependency; the slf4j-api jar. In runtime you also need a SLF4 You need to enable the Slf4jEventHandler in the 'event-handlers' 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). The String representation of the source object that is used when -creating the ``LoggingAdapter`` correspond to the name of the SL4FJ logger. +(e.g. logback.xml). .. code-block:: ruby @@ -227,6 +226,23 @@ creating the ``LoggingAdapter`` correspond to the name of the SL4FJ logger. loglevel = "DEBUG" } +The SLF4J logger selected for each log event is chosen based on the +:class:`Class[_]` of the log source specified when creating the +:class:`LoggingAdapter`, unless that was given directly as a string in which +case that string is used (i.e. ``LoggerFactory.getLogger(c: Class[_])`` is used in +the first case and ``LoggerFactory.getLogger(s: String)`` in the second). + +.. note:: + + Beware that the the actor system’s name is appended to a :class:`String` log + source if the LoggingAdapter was created giving an :class:`ActorSystem` to + the factory. If this is not intended, give a :class:`LoggingBus` instead as + shown below: + +.. code-block:: scala + + val log = Logging(system.eventStream, "my.nice.string") + Logging Thread and Akka Source in MDC ------------------------------------- From 8090769730c77c1cf48dbbfb26170862092eac72 Mon Sep 17 00:00:00 2001 From: Roland Kuhn Date: Fri, 3 Feb 2012 11:42:59 +0100 Subject: [PATCH 2/3] =?UTF-8?q?change=20=E2=80=9CClass[=5F]=E2=80=9D=20int?= =?UTF-8?q?o=20proper=20Java=20raw=20generics?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- akka-docs/java/logging.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/akka-docs/java/logging.rst b/akka-docs/java/logging.rst index 7ac04ca657..61e3269bd8 100644 --- a/akka-docs/java/logging.rst +++ b/akka-docs/java/logging.rst @@ -194,7 +194,7 @@ More fine grained log levels can be defined in the configuration of the SLF4J ba } The SLF4J logger selected for each log event is chosen based on the -:class:`Class[_]` of the log source specified when creating the +:class:`Class` of the log source specified when creating the :class:`LoggingAdapter`, unless that was given directly as a string in which case that string is used (i.e. ``LoggerFactory.getLogger(Class c)`` is used in the first case and ``LoggerFactory.getLogger(String s)`` in the second). From f62b50a41bf14102a1ea817ed8cc64cc259fb8dc Mon Sep 17 00:00:00 2001 From: Roland Kuhn Date: Fri, 3 Feb 2012 11:44:36 +0100 Subject: [PATCH 3/3] add missing parens --- akka-docs/java/logging.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/akka-docs/java/logging.rst b/akka-docs/java/logging.rst index 61e3269bd8..398a940468 100644 --- a/akka-docs/java/logging.rst +++ b/akka-docs/java/logging.rst @@ -208,7 +208,7 @@ the first case and ``LoggerFactory.getLogger(String s)`` in the second). .. code-block:: scala - final LoggingAdapter log = Logging.getLogger(system.eventStream, "my.nice.string"); + final LoggingAdapter log = Logging.getLogger(system.eventStream(), "my.nice.string"); Logging Thread and Akka Source in MDC -------------------------------------