diff --git a/akka-actor/src/main/scala/akka/event/Logging.scala b/akka-actor/src/main/scala/akka/event/Logging.scala
index d6e71aa586..0425b4c661 100644
--- a/akka-actor/src/main/scala/akka/event/Logging.scala
+++ b/akka-actor/src/main/scala/akka/event/Logging.scala
@@ -281,19 +281,34 @@ object Logging {
val debugFormat = "[DEBUG] [%s] [%s] [%s] %s".intern
/**
- * Obtain LoggingAdapter for the given application and source object. The
- * source is used to identify the source of this logging channel and must have
+ * Obtain LoggingAdapter for the given event stream (system) and source object.
+ * Note that there is an implicit conversion from [[akka.actor.ActorSystem]]
+ * to [[akka.event.LoggingBus]].
+ *
+ * The source is used to identify the source of this logging channel and must have
* a corresponding LogSource[T] instance in scope; by default these are
- * provided for Class[_], Actor, ActorRef and String types.
+ * provided for Class[_], Actor, ActorRef and String types. The source
+ * object is translated to a String according to the following rules:
+ *
+ *
if it is an Actor or ActorRef, its path is used
+ *
in case of a String it is used as is
+ *
in case of a class an approximation of its simpleName
+ *
and in all other cases the simpleName of its class
+ *
*/
def apply[T: LogSource](eventStream: LoggingBus, logSource: T): LoggingAdapter =
new BusLogging(eventStream, implicitly[LogSource[T]].genString(logSource))
/**
- * Java API: Obtain LoggingAdapter for the given application and source object. The
- * source object is used to identify the source of this logging channel; if it is
- * an Actor or ActorRef, its address is used, in case of a class an approximation of
- * its simpleName and in all other cases the simpleName of its class.
+ * Java API: Obtain LoggingAdapter for the given system and source object. The
+ * source object is used to identify the source of this logging channel. The source
+ * object is translated to a String according to the following rules:
+ *
+ *
if it is an Actor or ActorRef, its path is used
+ *
in case of a String it is used as is
+ *
in case of a class an approximation of its simpleName
+ *
and in all other cases the simpleName of its class
+ *
*/
def getLogger(system: ActorSystem, logSource: AnyRef): LoggingAdapter = apply(system.eventStream, LogSource.fromAnyRef(logSource))
@@ -354,6 +369,11 @@ object Logging {
*/
case object LoggerInitialized
+ /**
+ * Java API to create a LoggerInitialized message.
+ */
+ def loggerInitialized() = LoggerInitialized
+
class LoggerInitializationException(msg: String) extends AkkaException(msg)
trait StdOutLogger {
diff --git a/akka-docs/general/code/ConfigDocSpec.scala b/akka-docs/general/code/akka/docs/config/ConfigDocSpec.scala
similarity index 100%
rename from akka-docs/general/code/ConfigDocSpec.scala
rename to akka-docs/general/code/akka/docs/config/ConfigDocSpec.scala
diff --git a/akka-docs/general/configuration.rst b/akka-docs/general/configuration.rst
index 9328e19561..96467312bd 100644
--- a/akka-docs/general/configuration.rst
+++ b/akka-docs/general/configuration.rst
@@ -47,7 +47,7 @@ with ``/``. ``-Dconfig.resource=/dev.conf`` will load the ``dev.conf`` from the
You may also specify and parse the configuration programmatically in other ways when instantiating
the ``ActorSystem``.
-.. includecode:: code/ConfigDocSpec.scala
+.. includecode:: code/akka/docs/config/ConfigDocSpec.scala
:include: imports,custom-config
The ``ConfigFactory`` provides several methods to parse the configuration from various sources.
diff --git a/akka-docs/general/event-handler.rst b/akka-docs/general/event-handler.rst
deleted file mode 100644
index e6aa422b37..0000000000
--- a/akka-docs/general/event-handler.rst
+++ /dev/null
@@ -1,101 +0,0 @@
-.. _event-handler:
-
-Event Handler
-=============
-
-There is an Event Handler which takes the place of a logging system in Akka:
-
-.. code-block:: scala
-
- akka.event.EventHandler
-
-You can configure which event handlers should be registered at boot time. That is done using the 'event-handlers' element in
-the :ref:`configuration`. Here you can also define the log level.
-
-.. code-block:: ruby
-
- akka {
- # event handlers to register at boot time (EventHandler$DefaultListener logs to STDOUT)
- event-handlers = ["akka.event.EventHandler$DefaultListener"]
- loglevel = "DEBUG" # Options: ERROR, WARNING, INFO, DEBUG
- }
-
-The default one logs to STDOUT and is registered by default. It is not intended to be used for production. There is also an :ref:`slf4j` event handler available in the 'akka-slf4j' module.
-
-Example of creating a listener from Scala (from Java you just have to create an 'UntypedActor' and create a handler for these messages):
-
-.. code-block:: scala
-
- val errorHandlerEventListener = Actor.actorOf(new Actor {
- self.dispatcher = EventHandler.EventHandlerDispatcher
-
- def receive = {
- case EventHandler.Error(cause, instance, message) => ...
- case EventHandler.Warning(instance, message) => ...
- case EventHandler.Info(instance, message) => ...
- case EventHandler.Debug(instance, message) => ...
- case genericEvent => ...
- }
- })
-
-To add the listener:
-
-.. code-block:: scala
-
- EventHandler.addListener(errorHandlerEventListener)
-
-To remove the listener:
-
-.. code-block:: scala
-
- EventHandler.removeListener(errorHandlerEventListener)
-
-To log an event:
-
-.. code-block:: scala
-
- EventHandler.notify(EventHandler.Error(exception, this, message))
-
- EventHandler.notify(EventHandler.Warning(this, message))
-
- EventHandler.notify(EventHandler.Info(this, message))
-
- EventHandler.notify(EventHandler.Debug(this, message))
-
- EventHandler.notify(object)
-
-You can also use one of the direct methods (for a bit better performance):
-
-.. code-block:: scala
-
- EventHandler.error(exception, this, message)
-
- EventHandler.error(this, message)
-
- EventHandler.warning(this, message)
-
- EventHandler.info(this, message)
-
- EventHandler.debug(this, message)
-
-The event handler allows you to send an arbitrary object to the handler which you can handle in your event handler listener. The default listener prints it's toString String out to STDOUT.
-
-.. code-block:: scala
-
- EventHandler.notify(anyRef)
-
-The methods take a call-by-name parameter for the message to avoid object allocation and execution if level is disabled. The following formatting function will not be evaluated if level is INFO, WARNING, or ERROR.
-
-.. code-block:: scala
-
- EventHandler.debug(this, "Processing took %s ms".format(duration))
-
-From Java you need to nest the call in an if statement to achieve the same thing.
-
-.. code-block:: java
-
- if (EventHandler.isDebugEnabled()) {
- EventHandler.debug(this, String.format("Processing took %s ms", duration));
- }
-
-
diff --git a/akka-docs/general/index.rst b/akka-docs/general/index.rst
index f3cc0d2a7d..945b52a278 100644
--- a/akka-docs/general/index.rst
+++ b/akka-docs/general/index.rst
@@ -7,7 +7,5 @@ General
jmm
message-send-semantics
configuration
- event-handler
- slf4j
addressing
supervision
diff --git a/akka-docs/general/slf4j.rst b/akka-docs/general/slf4j.rst
deleted file mode 100644
index 296cbb7b48..0000000000
--- a/akka-docs/general/slf4j.rst
+++ /dev/null
@@ -1,42 +0,0 @@
-.. _slf4j:
-
-SLF4J
-=====
-
-This module is available in the 'akka-slf4j.jar'. It has one single dependency; the slf4j-api jar. In runtime you
-also need a SLF4J backend, we recommend `Logback `_:
-
- .. code-block:: scala
-
- lazy val logback = "ch.qos.logback" % "logback-classic" % "1.0.0" % "runtime"
-
-
-Event Handler
--------------
-
-This module includes a SLF4J Event Handler that works with Akka's standard Event Handler. You enabled it in the 'event-handlers' element in
-the :ref:`configuration`. Here you can also define the log level.
-
-.. code-block:: ruby
-
- akka {
- event-handlers = ["akka.event.slf4j.Slf4jEventHandler"]
- loglevel = "DEBUG"
- }
-
-Read more about how to use the :ref:`event-handler`.
-
-Logging thread in MDC
----------------------
-
-Since the logging is done asynchronously the thread in which the logging was performed is captured in
-Mapped Diagnostic Context (MDC) with attribute name ``sourceThread``.
-With Logback the thread name is available with ``%X{sourceThread}`` specifier within the pattern layout configuration::
-
-
-
- %date{ISO8601} %-5level %logger{36} %X{sourceThread} - %msg%n
-
-
-
-
\ No newline at end of file
diff --git a/akka-docs/java/code/akka/docs/event/LoggingDocTest.scala b/akka-docs/java/code/akka/docs/event/LoggingDocTest.scala
new file mode 100644
index 0000000000..2a55bdb81a
--- /dev/null
+++ b/akka-docs/java/code/akka/docs/event/LoggingDocTest.scala
@@ -0,0 +1,5 @@
+package akka.docs.event
+
+import org.scalatest.junit.JUnitSuite
+
+class LoggingDocTest extends LoggingDocTestBase with JUnitSuite
diff --git a/akka-docs/java/code/akka/docs/event/LoggingDocTestBase.java b/akka-docs/java/code/akka/docs/event/LoggingDocTestBase.java
new file mode 100644
index 0000000000..669caa14b1
--- /dev/null
+++ b/akka-docs/java/code/akka/docs/event/LoggingDocTestBase.java
@@ -0,0 +1,86 @@
+package akka.docs.event;
+
+//#imports
+import akka.event.Logging;
+import akka.event.LoggingAdapter;
+
+//#imports
+
+//#imports-listener
+import akka.event.Logging.InitializeLogger;
+import akka.event.Logging.Error;
+import akka.event.Logging.Warning;
+import akka.event.Logging.Info;
+import akka.event.Logging.Debug;
+
+//#imports-listener
+
+import org.junit.Test;
+
+import scala.Option;
+import static org.junit.Assert.*;
+
+import akka.actor.ActorSystem;
+import akka.actor.ActorRef;
+import akka.actor.UntypedActor;
+import akka.actor.UntypedActorFactory;
+
+public class LoggingDocTestBase {
+
+ @Test
+ public void useLoggingActor() {
+ ActorSystem system = ActorSystem.create("MySystem");
+ ActorRef myActor = system.actorOf(new UntypedActorFactory() {
+ public UntypedActor create() {
+ return new MyActor();
+ }
+ });
+ myActor.tell("test");
+ system.stop();
+ }
+
+ //#my-actor
+ class MyActor extends UntypedActor {
+ LoggingAdapter log = Logging.getLogger(getContext().system(), this);
+
+ @Override
+ public void preStart() {
+ log.debug("Starting");
+ }
+
+ @Override
+ public void preRestart(Throwable reason, Option