Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

custom logback adapter class only found when in jar file

I wrote my own logback adapter class. When I start the program with the respective class file in the classpath directly (inside a directory), logback can't find it.

ERROR in ch.qos.logback.core.joran.action.AppenderAction - Could not create an Appender of type [com....MyAppender]. ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type com....MyAppender
at ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type com....MyAppender
at ch.qos.logback.core.util.OptionHelper.instantiateByClassNameAndParameter(OptionHelper.java:73)
at ch.qos.logback.core.util.OptionHelper.instantiateByClassName(OptionHelper.java:48)

If I put it in a jar file, everything is fine.

I saw that logback is using it's own class loader and my problem occurs when I start my application using sbt and play. So the problem may lay there.

Any ideas on how I could troubleshoot this?

Using:

"com.typesafe.play" %% "play" % "2.3.9"
"ch.qos.logback" % "logback-core" % "1.1.3",
sbt launcher version 0.13.8
like image 217
max.ott Avatar asked Aug 30 '25 15:08

max.ott


1 Answers

I saw similar issue Play fails to load custom log back appender but it is still not resolved.

Proposed solution just leave it as is - it will work in the prod mode because all code would be precompiled in jar files. I hope you tried it in the prod mode as well.

like image 196
Andriy Kuba Avatar answered Sep 02 '25 06:09

Andriy Kuba