Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,11 @@ lazy val scala_libraries_3 = (project in file("scala-libraries-3"))
"com.github.pureconfig" %% "pureconfig-enumeratum" % "0.17.1"
),
libraryDependencies += "org.scalamock" %% "scalamock" % "5.1.0" % Test,
libraryDependencies += "com.softwaremill.retry" %% "retry" % "0.3.5"
libraryDependencies += "com.softwaremill.retry" %% "retry" % "0.3.5",
libraryDependencies ++= Seq(
"org.apache.logging.log4j" %% "log4j-api-scala" % "12.0",
"org.apache.logging.log4j" % "log4j-core" % "2.13.0" % Runtime
)
)

lazy val scala_strings = (project in file("scala-strings"))
Expand Down
13 changes: 13 additions & 0 deletions scala-libraries-3/src/main/resources/log4j2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
</Appenders>
<Loggers>
<Root level="info">
<AppenderRef ref="Console"/>
</Root>
</Loggers>
</Configuration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.baeldung.scala.log4j

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

import scala.util.{Failure, Success, Try}

object LoggingApp extends App with Logging {
logger.info("Writing an informative message to the log")
logger.debug("Writing a debug message to the log")
Try(1 / 0) match {
case Success(value) => logger.warn("Math has changed")
case Failure(exception) => logger.catching(exception)
}
}