Logback

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

Project Info

Project Info: Apache Pekko Dynamic Log Levels
Artifact
org.apache.pekko
pekko-management-loglevels-logback
1.0.0
JDK versions
OpenJDK 8
OpenJDK 11
Scala versions2.12.18, 2.13.12, 3.3.1
License
Home pagehttps://pekko.apache.org/
API documentation
Forums
Release notesRelease Notes
IssuesGitHub issues
Sourceshttps://github.com/apache/pekko-management

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

sbt
val PekkoManagementVersion = "1.0.0"
libraryDependencies ++= Seq(
  "org.apache.pekko" %% "pekko-management-loglevels-logback" % PekkoManagementVersion,
  "org.apache.pekko" %% "pekko-management" % PekkoManagementVersion
)
Gradle
def versions = [
  PekkoManagementVersion: "1.0.0",
  ScalaBinary: "2.13"
]
dependencies {
  implementation "org.apache.pekko:pekko-management-loglevels-logback_${versions.ScalaBinary}:${versions.PekkoManagementVersion}"
  implementation "org.apache.pekko:pekko-management_${versions.ScalaBinary}:${versions.PekkoManagementVersion}"
}
Maven
<properties>
  <pekko.management.version>1.0.0</pekko.management.version>
  <scala.binary.version>2.13</scala.binary.version>
</properties>
<dependencies>
  <dependency>
    <groupId>org.apache.pekko</groupId>
    <artifactId>pekko-management-loglevels-logback_${scala.binary.version}</artifactId>
    <version>${pekko.management.version}</version>
  </dependency>
  <dependency>
    <groupId>org.apache.pekko</groupId>
    <artifactId>pekko-management_${scala.binary.version}</artifactId>
    <version>${pekko.management.version}</version>
  </dependency>
</dependencies>

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

sbt
val PekkoVersion = "1.0.2"
libraryDependencies ++= Seq(
  "org.apache.pekko" %% "pekko-stream" % PekkoVersion,
  "org.apache.pekko" %% "pekko-slf4j" % PekkoVersion
)
Gradle
def versions = [
  PekkoVersion: "1.0.2",
  ScalaBinary: "2.13"
]
dependencies {
  implementation "org.apache.pekko:pekko-stream_${versions.ScalaBinary}:${versions.PekkoVersion}"
  implementation "org.apache.pekko:pekko-slf4j_${versions.ScalaBinary}:${versions.PekkoVersion}"
}
Maven
<properties>
  <pekko.version>1.0.2</pekko.version>
  <scala.binary.version>2.13</scala.binary.version>
</properties>
<dependencies>
  <dependency>
    <groupId>org.apache.pekko</groupId>
    <artifactId>pekko-stream_${scala.binary.version}</artifactId>
    <version>${pekko.version}</version>
  </dependency>
  <dependency>
    <groupId>org.apache.pekko</groupId>
    <artifactId>pekko-slf4j_${scala.binary.version}</artifactId>
    <version>${pekko.version}</version>
  </dependency>
</dependencies>

With Pekko 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 pekko.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:7626/loglevel/logback?logger=com.example.MyActor&level=DEBUG"

Classic and Internal Pekko Logger Level

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

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

If management read-only is set to false PUT requests to loglevel/pekko?level=[level name] will dynamically change that. Note that the allowed level for Pekko 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:7626/loglevel/pekko?level=DEBUG"