Created
December 8, 2020 17:41
-
-
Save zerosum/17d6b34a4ab93ee843e98d192f3261f9 to your computer and use it in GitHub Desktop.
jul-to-slf4j don't work with airframe-log 20.12.1+
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scalaVersion := "2.13.4" | |
libraryDependencies ++= Seq( | |
"org.wvlet.airframe" %% "airframe" % "20.12.0", | |
"org.slf4j" % "slf4j-api" % "1.7.30", | |
"org.slf4j" % "jul-to-slf4j" % "1.7.30", | |
"ch.qos.logback" % "logback-classic" % "1.2.3" | |
) | |
Compile / mainClass := Some("Main") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.slf4j.LoggerFactory | |
trait DoSomething { | |
private val logger = LoggerFactory.getLogger(classOf[DoSomething]) | |
def doLogging(): Unit = { | |
logger.info("doing something") | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// airframe 20.12.0 | |
// | |
$ sbt run | |
[info] welcome to sbt 1.4.4 (AdoptOpenJDK Java 1.8.0_252) | |
... | |
02:36:59.508 [run-main-0] INFO w.a.lifecycle.LifeCycleManager - [session:7af4aab] Starting a new lifecycle ... | |
02:36:59.514 [run-main-0] INFO w.a.lifecycle.LifeCycleManager - [session:7af4aab] ======== STARTED ======== | |
02:36:59.516 [run-main-0] DEBUG wvlet.airframe.AirframeSession - [session:7af4aab] Get dependency [DoSomething] (or create with factory) at Main.scala:11 | |
02:36:59.555 [run-main-0] DEBUG wvlet.airframe.AirframeSession - [session:7af4aab] Init [DoSomething -> DoSomething]: Main$$anon$1@20e8906f | |
02:36:59.561 [run-main-0] INFO DoSomething - doing something | |
02:36:59.562 [run-main-0] INFO w.a.lifecycle.LifeCycleManager - [session:7af4aab] Stopping the lifecycle ... | |
02:36:59.566 [run-main-0] INFO w.a.lifecycle.LifeCycleManager - [session:7af4aab] The lifecycle has stopped. | |
[success] Total time: 2 s, completed 2020/12/09 2:36:59 | |
// | |
// airframe 20.12.1 | |
// | |
$ sbt run | |
[info] welcome to sbt 1.4.4 (AdoptOpenJDK Java 1.8.0_252) | |
... | |
2020-12-09 02:37:56.244+0900 info [LifeCycleManager] [session:58457038] Starting a new lifecycle ... - (LifeCycleManager.scala:284) | |
2020-12-09 02:37:56.248+0900 info [LifeCycleManager] [session:58457038] ======== STARTED ======== - (LifeCycleManager.scala:288) | |
2020-12-09 02:37:56.350+0900 debug [AirframeSession] [session:58457038] Init [DoSomething -> DoSomething]: Main$$anon$1@10988963 - (AirframeSession.scala:196) | |
02:37:56.356 [run-main-0] INFO DoSomething - doing something | |
2020-12-09 02:37:56.359+0900 info [LifeCycleManager] [session:58457038] Stopping the lifecycle ... - (LifeCycleManager.scala:292) | |
2020-12-09 02:37:56.362+0900 info [LifeCycleManager] [session:58457038] The lifecycle has stopped. - (LifeCycleManager.scala:296) | |
[success] Total time: 5 s, completed 2020/12/09 2:37:56 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<configuration> | |
<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator"> | |
<resetJUL>true</resetJUL> | |
</contextListener> | |
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | |
<encoder> | |
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern> | |
</encoder> | |
</appender> | |
<root level="debug"> | |
<appender-ref ref="STDOUT"/> | |
</root> | |
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.slf4j.bridge.SLF4JBridgeHandler | |
import wvlet.airframe._ | |
object Main extends App { | |
SLF4JBridgeHandler.removeHandlersForRootLogger() | |
SLF4JBridgeHandler.install() | |
val design = newDesign.bind[DoSomething].toSingleton | |
design.build[DoSomething](x => x.doLogging()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment