Logging
Logging in the server and each tool is handled by Logback - an open source Java logging library. You are able to change the logging behaviour by specifying your own Logback XML configuration file. The default configuration that the EWB server and tools use is as follows:
<configuration>
<property name="LOG_NAME" value="weather-station-mapper"/>
<appender name="RollingFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${logsPath:-logs}/${LOG_NAME}.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- daily rollover -->
<fileNamePattern>${logsPath:-logs}/${LOG_NAME}.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- keep 180 days worth of history -->
<maxHistory>180</maxHistory>
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %5level %-31.31logger{31} - %msg%n</pattern>
</encoder>
</appender>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!-- encoders are assigned the type ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder>
<pattern>%white(%d{yyyy-MM-dd HH:mm:ss.SSS}) %highlight(%5level) - %msg%n</pattern>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="STDOUT"/>
<appender-ref ref="RollingFile"/>
</root>
</configuration>
The LOG_NAME
value is unique to each process so they all get their own unique log file.
Logs Directory
By default, logs will go into a directory called logs in the current working directory (that will generally be the directory that the jar was launched from). To specify a specific logs directory, you can add a Java system property argument when launching the jar.
java -DlogsPath=/path/to/logs/dir/ -jar ...
The ewb_server.sh
script, and running the data tools via the ewb_daily.sh
script make use of this argument passing
in the EWB_LOGS_DIR
variable from ewb.conf
.
Custom Logback Config
To make use of your own custom Logback configuration, a Java system property needs to be set when invoking any of the jars. For example:
java -Dlogback.configurationFile=<path to logback XML file> -jar ...
Logback provides extensive configuration options all documented on their website.