2

I am using Play Framework 2.4. This is a part of the default conf/logback.xml file Play 2.4

<!--
  ~ Copyright (C) 2009-2016 Lightbend Inc. <https://www.lightbend.com>
  -->
<!-- The default logback configuration that Play uses if no other configuration is provided -->
<configuration>

  <conversionRule conversionWord="coloredLevel" converterClass="play.api.libs.logback.ColoredLevel" />

  <appender name="FILE" class="ch.qos.logback.core.FileAppender">
     <file>${application.home}/logs/application.log</file>
     <encoder>
       <pattern>%date [%level] from %logger in %thread - %message%n%xException</pattern>
     </encoder>
  </appender>
</configuration>

You can see full version from here. My question is how exactly that ${application.home} can be resolved? I read this answer, but didn't work.

The exact situation is when I removed ${application.home} from <file></file> tag, the logs folder will be created outside (in Parallel with) the dist(play-restful-docker-1.0-SNAPSHOT) folder. (in production)

I can add the dist-name (play-restful-docker-1.0-SNAPSHOT) replacing ${application.home} and it creates logs folder inside the dist and works perfect. But it is not a good practice since it will have to be changed per every new version.

3
  • Can you give an example of what you are trying to achieve (ex: logs are placed in x/y/z, I want them at x/k/m)? Commented Jun 13, 2016 at 19:51
  • I have trouble to get your exact question? Commented Jun 14, 2016 at 9:58
  • I am trying to add a log file (inside <appender> tag), which keeps all the logs as the application up and running. Commented Jun 15, 2016 at 3:34

1 Answer 1

1

You could create your own conf/logback.xml and override the default one. The additional ":-." after application.home will cause it to default to the current directory if application.home is not defined. The default logback.xml of Play 2.5 does this automatically.

<configuration>    
  <conversionRule conversionWord="coloredLevel" converterClass="play.api.libs.logback.ColoredLevel" />    
  <appender name="FILE" class="ch.qos.logback.core.FileAppender">
     <file>${application.home:-.}/logs/application.log</file>
     <encoder>
       <pattern>%date [%level] from %logger in %thread - %message%n%xException</pattern>
     </encoder>
  </appender>
</configuration>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.