Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I configure system properties or logback configuration variables from typesafe config?
    primarykey
    data
    text
    <p>I have variables with defaults in my <code>logback.xml</code> configuration file, and I would like to be able to optionally set these variables from my typesafe config <code>application.conf</code> file. </p> <p>I am deploying the application using one-jar, and the <code>application.conf</code> file packaged up in the deployable jar contains defaults. I pass <code>-Dconfig.file=foo.conf</code> on execution to provide the path to a server-specific config file.</p> <p>Right now I can also pass <code>-Dlog.level</code> and other variables to override my defaults in <code>logback.xml</code>, and I also have to pass <code>-Dfile.encoding=UTF-8</code> on the command line. I'm looking for a way to be able to specify these properties in the typesafe config instead of on the command line. It feels like there should be a way to do it, but I can't find the magic words.</p> <p><strong>logback.xml:</strong></p> <pre><code>&lt;configuration&gt; &lt;appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"&gt; &lt;file&gt;${log.path:-logs/}/${log.file:-myLog.log}&lt;/file&gt; &lt;rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"&gt; &lt;!-- daily rollover --&gt; &lt;fileNamePattern&gt;logFile.%d{yyyy-MM-dd}.log&lt;/fileNamePattern&gt; &lt;!-- keep 15 days' worth of history --&gt; &lt;maxHistory&gt;${log.history.days:-15}&lt;/maxHistory&gt; &lt;/rollingPolicy&gt; &lt;encoder&gt; &lt;pattern&gt;%-4relative [%thread] %-5level %logger{35} - %msg%n&lt;/pattern&gt; &lt;/encoder&gt; &lt;/appender&gt; &lt;root level="${log.level:-INFO}"&gt; &lt;appender-ref ref="FILE" /&gt; &lt;/root&gt; &lt;/configuration&gt; </code></pre> <p><strong>application.conf (bundled):</strong></p> <pre><code>akka { log-config-on-start = false event-handlers = ["akka.event.slf4j.Slf4jEventHandler"] } </code></pre> <p><strong>sample server-specific app.conf:</strong></p> <pre><code>include "/application.conf" akka.log-config-on-start = true log.level = WARN // this is what I'd LIKE to be able to do </code></pre> <p><strong>How I'm currently running the app:</strong></p> <pre><code>java -Dfile.encoding=UTF-8 -Dconfig.file=myApp.conf -Dlog.level=WARN -jar myApp_2.10-0.1-one-jar.jar </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload