Skip to content

Commit

Permalink
removed file name config from logback.xml because of a bug in logback…
Browse files Browse the repository at this point in the history
… core which causes the creation of tmp files that are never deleted;

add possibility to configure clean up of old log files and archives at start up;

Signed-off-by: Stefan Maute <stefan.maute@bosch.io>
  • Loading branch information
Stefan Maute committed Mar 2, 2022
1 parent 8abf9d5 commit 1097d9d
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion concierge/service/src/main/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>info</level>
</filter>
<file>/var/log/ditto/concierge.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- daily rollover as default-->
<fileNamePattern>${DITTO_LOGGING_FILE_NAME_PATTERN:-/var/log/ditto/concierge.log.%d{yyyy-MM-dd}.gz}</fileNamePattern>
<!-- Keep 10 days' worth of history capped at 1GB total size as default -->
<maxHistory>${DITTO_LOGGING_MAX_LOG_FILE_HISTORY_IN_DAYS:-10}</maxHistory>
<totalSizeCap>${DITTO_LOGGING_TOTAL_LOG_FILE_SIZE:-1GB}</totalSizeCap>
<cleanHistoryOnStart>${DITTO_LOGGING_CLEAN_HISTORY_ON_START:-false}</cleanHistoryOnStart>
</rollingPolicy>
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
<customFields>{"appname":"concierge","instance_index":"${INSTANCE_INDEX}"}</customFields>
Expand Down
2 changes: 1 addition & 1 deletion connectivity/service/src/main/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>info</level>
</filter>
<file>/var/log/ditto/connectivity.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- daily rollover as default -->
<fileNamePattern>${DITTO_LOGGING_FILE_NAME_PATTERN:-/var/log/ditto/connectivity.log.%d{yyyy-MM-dd}.gz}</fileNamePattern>
<!-- Keep 10 days' worth of history capped at 1GB total size as default -->
<maxHistory>${DITTO_LOGGING_MAX_LOG_FILE_HISTORY_IN_DAYS:-10}</maxHistory>
<totalSizeCap>${DITTO_LOGGING_TOTAL_LOG_FILE_SIZE:-1GB}</totalSizeCap>
<cleanHistoryOnStart>${DITTO_LOGGING_CLEAN_HISTORY_ON_START:-false}</cleanHistoryOnStart>
</rollingPolicy>
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
<customFields>{"appname":"connectivity","instance_index":"${INSTANCE_INDEX}"}</customFields>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,12 @@ Gathering logs for a running Ditto installation can be achieved by:
* configure `DITTO_LOGGING_LOGSTASH_SERVER` to contain the endpoint of a logstash server

* writing logs to log files: this can be done by setting the environment variable `DITTO_LOGGING_FILE_APPENDER` to `true`
* configure the amount of log files, and the total amount of space used for logs files via these two environment
variables:
* configure the amount of log files, and the total amount of space used for logs files via these environment
variables. It is also possible to clean up old log files and archives at start up:
* `DITTO_LOGGING_FILE_NAME_PATTERN` (default: /var/log/ditto/<service-name>.log.%d{yyyy-MM-dd}.gz)
* `DITTO_LOGGING_MAX_LOG_FILE_HISTORY_IN_DAYS` (default: 10)
* `DITTO_LOGGING_TOTAL_LOG_FILE_SIZE` (default: 1GB)
* `DITTO_LOGGING_CLEAN_HISTORY_ON_START` (default: false)
* the format in which logging is done is "LogstashEncoder" format - that way the logfiles may easily be imported into
an ELK stack
* when running Ditto in Kubernetes apply the `ditto-log-files.yaml` to your Kubernetes cluster in order to
Expand Down
2 changes: 1 addition & 1 deletion gateway/service/src/main/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>info</level>
</filter>
<file>/var/log/ditto/gateway.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- daily rollover as default-->
<fileNamePattern>${DITTO_LOGGING_FILE_NAME_PATTERN:-/var/log/ditto/gateway.log.%d{yyyy-MM-dd}.gz}</fileNamePattern>
<!-- Keep 10 days' worth of history capped at 1GB total size as default-->
<maxHistory>${DITTO_LOGGING_MAX_LOG_FILE_HISTORY_IN_DAYS:-10}</maxHistory>
<totalSizeCap>${DITTO_LOGGING_TOTAL_LOG_FILE_SIZE:-1GB}</totalSizeCap>
<cleanHistoryOnStart>${DITTO_LOGGING_CLEAN_HISTORY_ON_START:-false}</cleanHistoryOnStart>
</rollingPolicy>
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
<customFields>{"appname":"gateway","instance_index":"${INSTANCE_INDEX}"}</customFields>
Expand Down
2 changes: 1 addition & 1 deletion policies/service/src/main/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>info</level>
</filter>
<file>/var/log/ditto/policies.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- daily rollover as default-->
<fileNamePattern>${DITTO_LOGGING_FILE_NAME_PATTERN:-/var/log/ditto/policies.log.%d{yyyy-MM-dd}.gz}</fileNamePattern>
<!-- Keep 10 days' worth of history capped at 1GB total size as default -->
<maxHistory>${DITTO_LOGGING_MAX_LOG_FILE_HISTORY_IN_DAYS:-10}</maxHistory>
<totalSizeCap>${DITTO_LOGGING_TOTAL_LOG_FILE_SIZE:-1GB}</totalSizeCap>
<cleanHistoryOnStart>${DITTO_LOGGING_CLEAN_HISTORY_ON_START:-false}</cleanHistoryOnStart>
</rollingPolicy>
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
<customFields>{"appname":"policies","instance_index":"${INSTANCE_INDEX}"}</customFields>
Expand Down
3 changes: 2 additions & 1 deletion things/service/src/main/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,14 @@
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>info</level>
</filter>
<file>/var/log/ditto/things.log</file>
<!-- <file>/var/log/ditto/things.log</file>-->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- daily rollover as default-->
<fileNamePattern>${DITTO_LOGGING_FILE_NAME_PATTERN:-/var/log/ditto/things.log.%d{yyyy-MM-dd}.gz}</fileNamePattern>
<!-- Keep 10 days' worth of history capped at 1GB total size as default -->
<maxHistory>${DITTO_LOGGING_MAX_LOG_FILE_HISTORY_IN_DAYS:-10}</maxHistory>
<totalSizeCap>${DITTO_LOGGING_TOTAL_LOG_FILE_SIZE:-1GB}</totalSizeCap>
<cleanHistoryOnStart>${DITTO_LOGGING_CLEAN_HISTORY_ON_START:-false}</cleanHistoryOnStart>
</rollingPolicy>
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
<customFields>{"appname":"things","instance_index":"${INSTANCE_INDEX}"}</customFields>
Expand Down
2 changes: 1 addition & 1 deletion thingsearch/service/src/main/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>info</level>
</filter>
<file>/var/log/ditto/thing-search.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- daily rollover as default-->
<fileNamePattern>${DITTO_LOGGING_FILE_NAME_PATTERN:-/var/log/ditto/thing-search.log.%d{yyyy-MM-dd}.gz}</fileNamePattern>
<!-- Keep 10 days' worth of history capped at 1GB total size as default -->
<maxHistory>${DITTO_LOGGING_MAX_LOG_FILE_HISTORY_IN_DAYS:-10}</maxHistory>
<totalSizeCap>${DITTO_LOGGING_TOTAL_LOG_FILE_SIZE:-1GB}</totalSizeCap>
<cleanHistoryOnStart>${DITTO_LOGGING_CLEAN_HISTORY_ON_START:-false}</cleanHistoryOnStart>
</rollingPolicy>
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
<customFields>{"appname":"thing-search","instance_index":"${INSTANCE_INDEX}"}</customFields>
Expand Down

0 comments on commit 1097d9d

Please sign in to comment.