【问题标题】:in play 2.4 logback configurations, where is ${application.home} defined?在 play 2.4 logback 配置中,${application.home} 定义在哪里?
【发布时间】:2023-04-01 15:53:01
【问题描述】:

此处的链接向您展示了如何配置自定义记录器。

https://www.playframework.com/documentation/2.4.x/SettingsLogger

我只是想知道 ${applicaation.home} 在哪里定义,因为它似乎没有在我的生产环境中定义。

【问题讨论】:

    标签: playframework playframework-2.4


    【解决方案1】:

    如@user316607 所示,Play 应在Logger.configure method 中自行定义application.home。如果您看到的是 application.home_IS_UNDEFINED 值,而您正在使用 compile-time dependency injection,则您需要自己在 ApplicationLoader 中调用 Logger.configure,如 this blog post 中所述:

    class MyApplicationLoader extends ApplicationLoader {
      def load(context: Context) = {
        new MyComponents(context).application
      }
    }
    
    class MyComponents(context: Context) extends BuiltInComponentsFromContext(context) {
      // You have to call Logger.configure manually or logback won't work
      Logger.configure(context.environment)
    
      // ... The rest of your app initialization code ...
    }
    

    【讨论】:

    • 对于 Play 2.5 中的编译时 DI,Logger.configure 已移至 LoggerConfigurator,以及其他一些 changes。第 60-67 行 here 显示了配置 Logger 的示例。
    【解决方案2】:

    appliation.home 由 play framework 本身定义。

    https://github.com/playframework/playframework/blob/2.4.x/framework/src/play/src/main/scala/play/api/Logger.scala#L199

    你一定有另一个问题。

    【讨论】:

      【解决方案3】:

      我觉得自己很愚蠢。我刚刚意识到这是 logback 的一部分,而不是游戏的一部分。您可以像这样定义自己的变量:

      <property name="USER_HOME" value="/home/sebastien" />
      

      更多详情请点击此处结帐链接: http://logback.qos.ch/manual/configuration.html#definingProps

      【讨论】:

      • 这样,应用很难托管在不同的服务器上吧?
      猜你喜欢
      • 1970-01-01
      • 2020-07-27
      • 2010-12-20
      • 1970-01-01
      • 1970-01-01
      • 2016-07-02
      • 2018-09-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多