Play fails to load custom log back appender

后端 未结 2 545
执念已碎
执念已碎 2021-02-18 21:28

I have created a custom logback appender. But play gives a ClassNotFound exception for the appender.

Following is my appender

package log

import ch.qos.         


        
相关标签:
2条回答
  • 2021-02-18 21:51

    Although the solution of adding a separate jar file works, I found another solution which adds the benefit of accessing your uri as defined in your application.conf file.

    Create an EagerSingleton in your Module. This will get called during startup. Inside this, construct your MongoDB Appender and add it to the logger you want to log to MongoDB. The benefit is that you can inject your Configuration into this singleton and then access config settings to pass on to your MongoDB Appender.

    0 讨论(0)
  • 2021-02-18 22:13

    It seems that play's dynamically compiled classes in dev mode are not available for logback. I'm struggling with the same issue. Putting my custom appender to a separate jar file works for me. I assume in prod with staged final jar files this should not be a problem.

    0 讨论(0)
提交回复
热议问题