Log4j Scala API is a Scala logging facade based on Log4j 2. Support for Scala versions 2.10, 2.11, and 2.12 is provided, and experimental support for pre-release versions of 2.13 is also provided. Log4j Scala API uses Log4j 2.x as its logging backend by default, but this can also be replaced with compatible libraries (e.g., Logback). While this library is not required to use Log4j API in Scala, it does provide idiomatic Scala APIs which are friendlier to use in Scala programs than the Java APIs.


Using the Scala API is as simple as mixing in the Logging trait to your class. Example:

import org.apache.logging.log4j.scala.Logging
import org.apache.logging.log4j.Level

class MyClass extends BaseClass with Logging {
  def doStuff(): Unit = {
    logger.info("Doing stuff")
  def doStuffWithLevel(level: Level): Unit = {
    logger(level, "Doing stuff with arbitrary level")
  def doStuffWithUser(user: User): Unit = {
    logger.info(s"Doing stuff with ${user.getName}.")

API Documentation

Scala Version API Link

Scala 2.10


Scala 2.11


Scala 2.12


Scala 2.13



Log4j Scala API uses Log4j configuration by default. This supports XML, properties files, and Java-based builders, as well as JSON and YAML with additional dependencies.

Substituting Parameters

Unlike in Java, Scala provides native functionality for string interpolation beginning in Scala 2.10. As all logger calls are implemented as macros, using string interpolation directly does not require additional if checks. For example:

logger.debug(s"Logging in user ${user.getName} with birthday ${user.calcBirthday}")

Logger Names

Most logging implementations use a hierarchical scheme for matching logger names with logging configuration. In this scheme the logger name hierarchy is represented by '.' characters in the logger name, in a fashion very similar to the hierarchy used for Java/Scala package names. The Logger property added by the Logging trait follows this convention: the trait ensures the Logger is automatically named according to the class it is being used in.


Apache Log4j Scala API is distributed under the Apache License, version 2.0. The link in the Mirrors column should display a list of available mirrors with a default selection based on your inferred location. If you do not see that page, try a different browser. The checksum and signature are links to the originals on the main distribution server.

Distribution Mirrors Signature SHA-256 SHA-512

Apache Log4j Scala API binary (tar.gz)





Apache Log4j Scala API binary (zip)





Apache Log4j Scala API source (tar.gz)





Apache Log4j Scala API source (zip)





It is essential that you verify the integrity of the downloaded files using the PGP signatures or the SHA-2 checksum files (SHA-256 or SHA-512). Please read Verifying Apache HTTP Server Releases for more information on why you should verify our releases.

The PGP signatures can be verified using PGP or GPG. First download the KEYS as well as the asc signature file for the relevant distribution. Make sure you get these files from the main distribution directory, rather than from a mirror. Then verify the signatures using:

gpg --import KEYS
gpg --verify apache-log4j-api-scala-12.0-bin.tar.gz.asc apache-log4j-api-scala-12.0-bin.tar.gz
gpg --verify apache-log4j-api-scala-12.0-bin.zip.asc apache-log4j-api-scala-12.0-bin.zip
gpg --verify apache-log4j-api-scala-12.0-src.tar.gz.asc apache-log4j-api-scala-12.0-src.tar.gz
gpg --verify apache-log4j-api-scala-12.0-src.zip.asc apache-log4j-api-scala-12.0-src.zip

Log4j Scala API requires Log4j API.

Using SBT

How to add Log4j Scala API to your project using Log4j 2:

libraryDependencies ++= Seq(
  "org.apache.logging.log4j" %% "log4j-api-scala" % "12.0",
  "org.apache.logging.log4j" % "log4j-core" % "2.13.0" % Runtime


Version 12.0

New Features

Migrate log4j-api-scala to sbt.


Add release distribution script.


Add OSGi metadata to release jars.


Add release audit information to build.


Add changelog to site.


Add required license files to sbt output artifacts.


Add sbt-site plugin and website configuration.


Add Jenkins pipeline for sbt build.


Add support for Scala 2.13.

Bug Fixes



Update Log4j Scala API for 2.13 from 2.13.0-M2 to 2.13.0-M3.


Update Log4j from 2.9.1 to 2.13.2.


Update log4j-api-scala_2.11 from Scala 2.11.8 to 2.11.11.


Update log4j-api-scala_2.12 from Scala 2.12.1 to 2.12.3.


Update Log4j dependency from 2.8.1 to 2.9.1.


Update log4j-api-scala_2.12 from Scala 2.12.3 to 2.12.4.



Building From Source

The following information is for developers who wish to modify Log4j Scala API or contribute. If your goal is to add logging to your application, then you can use the pre-built binaries instead.
./sbt auditCheck
./sbt "+ package"


You have found a bug or you have an idea for a cool new feature? Contributing code is a great way to give something back to the open source community. Before you dig right into the code there are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things.

Getting Started

  • Make sure you have a Jira account.

  • Make sure you have a GitHub account.

  • If you’re planning to implement a new feature it makes sense to discuss your changes on the dev list first. This way you can make sure you’re not wasting your time on something that isn’t considered to be in Apache Log4j’s scope.

  • Submit a ticket for your issue, assuming one does not already exist.

  • Clearly describe the issue including steps to reproduce when it is a bug.

  • Make sure you fill in the earliest version that you know has the issue.

  • Fork the repository on GitHub.

Making Changes

  • Create a topic branch from where you want to base your work (this is usually the master branch).

  • Make commits of logical units.

  • Respect the original code style:

  • Only use spaces for indentation.

  • Create minimal diffs - disable on save actions like reformat source code or organize imports. If you feel the source code should be reformatted create a separate PR for this change.

  • Check for unnecessary whitespace with git diff --check before committing.

  • Make sure your commit messages are in the proper format. Your commit message should contain the key of the Jira issue.

  • Make sure you have added the necessary tests for your changes.

  • Run all the tests with sbt "+ test" to assure nothing else was accidentally broken.

Making Trivial Changes

For changes of a trivial nature to comments and documentation, it is not always necessary to create a new ticket in JIRA. In this case, it is appropriate to start the first line of a commit with '(doc)' instead of a ticket number.

Submitting Changes

  • Sign the Contributor License Agreement if you haven’t already.

  • Push your changes to a topic branch in your fork of the repository.

  • Submit a pull request to the repository in the apache organization.

  • Update your Jira ticket and include a link to the pull request in the ticket.

Release Audit Report

Generated at: 2020-05-03T11:24:27-05:00


  • Notes: 0

  • Binaries: 0

  • Archives: 0

  • Standards: 4

  • Apache Licensed: 4

  • Generated Documents: 0

    • JavaDocs are generated, thus a license header is optional. Generated files do not require license headers.

  • Unknown Licenses: 0


Files with Apache License headers will be marked AL. Binary files (which do not require any license headers) will be marked B. Compressed archives will be marked A. Notices, licenses etc. will be marked N.

OK? Type File