Skip to content

Commit 6e5d6a7

Browse files
committed
Bridge JUL to SLF4J, fix docker build
1 parent 25ad6dc commit 6e5d6a7

File tree

5 files changed

+21
-7
lines changed

5 files changed

+21
-7
lines changed

backend/src/main/resources/application.conf

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ db {
2828
migrate-on-start = ${?MIGRATE_ON_START}
2929

3030
driver = "org.postgresql.Driver"
31-
32-
connect-thread-pool-size = 32
3331
}
3432

3533
email {

backend/src/main/resources/logback.xml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

3-
<configuration scan="true">
3+
<configuration>
4+
<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
5+
<resetJUL>true</resetJUL>
6+
</contextListener>
7+
48
<if condition='p("LOGBACK_JSON_ENCODE").equals("true")'>
59
<then>
610
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
@@ -31,5 +35,4 @@
3135
<root level="${LOG_LEVEL:-INFO}">
3236
<appender-ref ref="STDOUT"/>
3337
</root>
34-
3538
</configuration>

backend/src/main/scala/com/softwaremill/bootzooka/Main.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@ package com.softwaremill.bootzooka
33
import com.softwaremill.bootzooka.logging.Logging
44
import ox.logback.InheritableMDC
55
import ox.{IO, Ox, OxApp, never}
6+
import org.slf4j.bridge.SLF4JBridgeHandler
67

78
object Main extends OxApp.Simple with Logging:
9+
// route JUL to SLF4J
10+
SLF4JBridgeHandler.removeHandlersForRootLogger()
11+
SLF4JBridgeHandler.install()
12+
813
InheritableMDC.init
914
Thread.setDefaultUncaughtExceptionHandler((t, e) => logger.error("Uncaught exception in thread: " + t, e))
1015

backend/src/main/scala/com/softwaremill/bootzooka/infrastructure/DBConfig.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@ import com.softwaremill.bootzooka.config.Sensitive
44
import pureconfig.ConfigReader
55
import pureconfig.generic.derivation.default.*
66

7-
case class DBConfig(username: String, password: Sensitive, url: String, migrateOnStart: Boolean, driver: String, connectThreadPoolSize: Int)
8-
derives ConfigReader
7+
case class DBConfig(username: String, password: Sensitive, url: String, migrateOnStart: Boolean, driver: String) derives ConfigReader

build.sbt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ val jsonDependencies = Seq(
4343

4444
val loggingDependencies = Seq(
4545
"ch.qos.logback" % "logback-classic" % "1.5.8",
46+
"org.slf4j" % "jul-to-slf4j" % "1.7.36", // forward e.g. otel logs which use JUL to SLF4J
4647
"com.softwaremill.ox" %% "mdc-logback" % oxVersion,
4748
"org.codehaus.janino" % "janino" % "3.1.12" % Runtime,
4849
"net.logstash.logback" % "logstash-logback-encoder" % "8.0" % Runtime
@@ -181,7 +182,15 @@ lazy val backend: Project = (project in file("backend"))
181182
streams.value.log.info(s"Copying the webapp resources from $source to $target")
182183
IO.copyDirectory(source, target)
183184
},
184-
copyWebapp := copyWebapp.dependsOn(yarnTask.toTask(" build")).value,
185+
copyWebapp := copyWebapp
186+
.dependsOn(
187+
Def
188+
.sequential(
189+
generateOpenAPIDescription,
190+
yarnTask.toTask(" build")
191+
)
192+
)
193+
.value,
185194
generateOpenAPIDescription := Def.taskDyn {
186195
val log = streams.value.log
187196
val targetPath = ((Compile / target).value / "openapi.yaml").toString

0 commit comments

Comments
 (0)