Dynamic Log Levels

Dynamic Log Levels for Logback hooks into Akka Management and provides a route where log levels can be read and set over HTTP.

Project Info

Project Info: Dynamic Log Levels
Artifact
com.lightbend.akka.management
akka-management-loglevels-logback
1.0.8
JDK versions
Adopt OpenJDK 8 with Hotspot
Adopt OpenJDK 11 with Hotspot
Scala versions2.11.12, 2.12.10, 2.13.0
License
Readiness level
Since 0.16.0, 2019-11-29
Home pagehttps://akka.io/
API documentation
Forums
Release notesGitHub releases
IssuesGitHub issues
Sourceshttps://github.com/akka/akka-management

Requires Akka Management and that the application uses Logback as logging backend.

sbt
libraryDependencies ++= Seq(
  "com.lightbend.akka.management" %% "akka-management-loglevels-logback" % "1.0.8",
  "com.lightbend.akka.management" %% "akka-management" % "1.0.8"
)
Gradle
versions += [
  ScalaBinary: "2.12"
]
dependencies {
  compile group: 'com.lightbend.akka.management', name: "akka-management-loglevels-logback_${versions.ScalaBinary}", version: '1.0.8',
  compile group: 'com.lightbend.akka.management', name: "akka-management_${versions.ScalaBinary}", version: '1.0.8'
}
Maven
<properties>
  <scala.binary.version>2.12</scala.binary.version>
</properties>
<dependency>
  <groupId>com.lightbend.akka.management</groupId>
  <artifactId>akka-management-loglevels-logback_${scala.binary.version}</artifactId>
  <version>1.0.8</version>
</dependency>
<dependency>
  <groupId>com.lightbend.akka.management</groupId>
  <artifactId>akka-management_${scala.binary.version}</artifactId>
  <version>1.0.8</version>
</dependency>

Akka Management and akka-management-loglevels-logback can be used with Akka 2.5.27 or 2.6.5 or later. You have to override the following Akka dependencies by defining them explicitly in your build and define the Akka version to the one that you are using. Latest patch version of Akka is recommended and a later version than 2.6.5 can be used.

sbt
val AkkaVersion = "2.6.5"
libraryDependencies ++= Seq(
  "com.typesafe.akka" %% "akka-stream" % AkkaVersion,
  "com.typesafe.akka" %% "akka-slf4j" % AkkaVersion
)
Gradle
versions += [
  AkkaVersion: "2.6.5",
  ScalaBinary: "2.12"
]
dependencies {
  compile group: 'com.typesafe.akka', name: "akka-stream_${versions.ScalaBinary}", version: versions.AkkaVersion,
  compile group: 'com.typesafe.akka', name: "akka-slf4j_${versions.ScalaBinary}", version: versions.AkkaVersion
}
Maven
<properties>
  <akka.version>2.6.5</akka.version>
  <scala.binary.version>2.12</scala.binary.version>
</properties>
<dependency>
  <groupId>com.typesafe.akka</groupId>
  <artifactId>akka-stream_${scala.binary.version}</artifactId>
  <version>${akka.version}</version>
</dependency>
<dependency>
  <groupId>com.typesafe.akka</groupId>
  <artifactId>akka-slf4j_${scala.binary.version}</artifactId>
  <version>${akka.version}</version>
</dependency>

With Akka Management started and this module on the classpath the module is automatically picked up and provides the following two HTTP routes:

Reading Logger Levels

A HTTP GET request to loglevel/logback?logger=[logger name] will return the log level of that logger.

Changing Logger Levels

Only enabled if akka.management.http.route-providers-read-only is set to false.

Warning

If enabling this make sure to properly secure your endpoint with HTTPS and authentication or else anyone with access to the system could change logger levels and potentially do a DoS attack by setting all loggers to TRACE.

A HTTP PUT request to loglevel/logback?logger=[logger name]&level=[level name] will change the level of that logger on the JVM the ActorSystem runs on.

For example using curl:

curl -X PUT "http://127.0.0.1:8558/loglevel/logback?logger=com.example.MyActor&level=DEBUG"

Classic and Internal Akka Logger Level

Internal Akka actors and classic Akka does logging through the built in API there is an additional level of filtering using the akka.loglevel setting. If you have not set akka.loglevel to DEBUG (recommended) log entries from the classic logging API may never reach the logger backend at all.

The current level configured with akka.loglevel can be inspected with a GET request to loglevel/akka.

If management read-only is set to false PUT requests to loglevel/akka?level=[level name] will dynamically change that. Note that the allowed level for Akka Classic logging is a subset of the loglevels supported by SLF4j, valid values are OFF, DEBUG, INFO, WARNING and ERROR.

For example using curl:

curl -X PUT "http://127.0.0.1:8558/loglevel/akka?level=DEBUG"
Found an error in this documentation? The source code for this page can be found here. Please feel free to edit and contribute a pull request.