Playframework 在Play 2.2.x中使用自定义日志记录操作

Playframework 在Play 2.2.x中使用自定义日志记录操作,playframework,logback,Playframework,Logback,在Play.Logger.debug()、Play.Logger.info()等(使用默认静态类Logger,而不是任何创建的实例)的Play框架中使用自定义记录器的所有示例都需要将自写类写入conf/Logger.xml。这在开发模式下不起作用,我得到一个例外 Could not create an Appender of type [my.example.log.LoggerConnector].ch.qos.logback.core.util.DynamicClassLoadingExc

在Play.Logger.debug()、Play.Logger.info()等(使用默认静态类Logger,而不是任何创建的实例)的Play框架中使用自定义记录器的所有示例都需要将自写类写入conf/Logger.xml。这在开发模式下不起作用,我得到一个例外

 Could not create an Appender of type [my.example.log.LoggerConnector].ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type my.example
.log.LoggerConnector
        at ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type my.example.log.LoggerConnector
        at      at ch.qos.logback.core.util.OptionHelper.instantiateByClassNameAndParameter(OptionHelper.java:73)

配置看起来像

当我通过
start
运行应用程序时,它会工作

有人知道在运行时注册记录器的方法吗?记录器必须在启动应用程序后实例化,因为它应该连接到一些现有功能


有什么提示,有什么帮助吗?

您是说您的自定义appender(LoggerConnector)在一个独立的应用程序中工作,该应用程序只使用logback,但在play framework中使用时不工作?您还说明了在运行时注册记录器的另一个问题。这是第二个问题吗?对于play(使用sbt,简单构建工具),启动应用程序有不同的可能性,“启动”和“运行”。“开始”接近部署模式,“运行”接近开发模式。使用“开始”时,我的LoggerConnector正常工作,而使用“运行”时则不正常。我希望找到一种方法来注册它,而不是在启动时,而是在运行时来解决这个启动问题。你能发布你的LoggerConnector类吗?我首先在我的“普通”包中尝试了它,“包日志”;是一个修复搜索。链接有错误,新链接为