Clarify logger names
1 file changed
tree: c7e916f0beb5ecb40f533fe1c64a3bbae722c30d
  1. log4j-api-scala-sample/
  2. log4j-scala-distribution/
  3. project/
  4. src/
  5. .gitignore
  6. build.sbt
  7. BUILDING.md
  8. CONTRIBUTING.md
  9. Jenkinsfile
  10. LICENSE.txt
  11. NOTICE.txt
  12. pom.xml
  13. README.md
  14. sbt
  15. version.sbt
README.md

Apache Log4j 2 Scala API

Log4j Scala API is a Scala logging facade based on Log4j 2. This supports Scala 2.10, and 2.11 on Java 7 at minimum, and Scala 2.12 on Java 8 at minimum. Log4j Scala API provides Log4j 2 as its default logging implementation, but this is not strictly required (e.g., this API can also be used with Logback or other Log4j 2 API provider implementations). Idiomatic Scala features are provided as an alternative to using the Log4j 2 Java API.

Note that this Scala API was versioned and released in sync with Log4j up until version 2.8.2, but from now on it will be versioned and released independently, that's why the version was bumped to 11.0.

Build Status

Usage

SBT users can add the following dependencies to their build.sbt file:

libraryDependencies ++= Seq(
  "org.apache.logging.log4j" %% "log4j-api-scala" % "11.0",
  "org.apache.logging.log4j" % "log4j-api" % "2.8.2",
  "org.apache.logging.log4j" % "log4j-core" % "2.8.2" % Runtime
)

Basic usage of the API:

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}.")
  }
}

Documentation

The Log4j Scala API is documented in more detail in the Log4j 2 manual and in the ScalaDocs.

Requirements

Log4j Scala API requires at least Java 7 for Scala 2.10/2.11, or Java 8 for Scala 2.12. This also requires Log4j 2 API, but it is specified as transitive dependencies automatically if you are using SBT, Maven, Gradle, or some other similar build system. This also requires Log4j 2 Core (or possibly an other implementation of Log4j 2 API) as a runtime dependency. Some Log4j 2 Core features require optional dependencies which are documented in the Log4j 2 manual.

License

Apache Log4j 2 is distributed under the Apache License, version 2.0.

Download

How to download Log4j, and how to use it from SBT, Maven, Ivy and Gradle. You can access the latest development snapshot by using the Maven repository https://repository.apache.org/snapshots, see Snapshot builds.

Issue Tracking

Issues, bugs, and feature requests should be submitted to the JIRA issue tracking system for this project.

Pull request on GitHub are welcome, but please open a ticket in the JIRA issue tracker first, and mention the JIRA issue in the Pull Request.

Building From Source

Log4j Scala API requires Maven 3 and Java 8 to build. To install to your local Maven repository, execute the following:

mvn install

Contributing

We love contributions! Take a look at our contributing page.