From 09b1537c0a0c912c87639b816da61323752cabd8 Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Thu, 3 Nov 2016 09:58:36 -0700 Subject: [PATCH] Update default config to ensure logs go to stdout --- 1.5/Dockerfile | 12 ++++++++---- 2.0/Dockerfile | 12 ++++++++---- 2.1/Dockerfile | 12 ++++++++---- 2.2/Dockerfile | 12 ++++++++---- 2.3/Dockerfile | 12 ++++++++---- 2.4/Dockerfile | 12 ++++++++---- 5.0/Dockerfile | 12 ++++++++---- Dockerfile.template | 12 ++++++++---- 8 files changed, 64 insertions(+), 32 deletions(-) diff --git a/1.5/Dockerfile b/1.5/Dockerfile index 9358231cd..445f8a59a 100644 --- a/1.5/Dockerfile +++ b/1.5/Dockerfile @@ -40,11 +40,15 @@ ENV PATH /opt/logstash/bin:$PATH # necessary for 5.0+ (overriden via "--path.settings", ignored by < 5.0) ENV LS_SETTINGS_DIR /etc/logstash # comment out some troublesome configuration parameters -# path.log: logs should go to stdout # path.config: No config files found: /etc/logstash/conf.d/* -RUN set -ex \ - && if [ -f "$LS_SETTINGS_DIR/logstash.yml" ]; then \ - sed -ri 's!^(path.log|path.config):!#&!g' "$LS_SETTINGS_DIR/logstash.yml"; \ +RUN set -ex; \ + if [ -f "$LS_SETTINGS_DIR/logstash.yml" ]; then \ + sed -ri 's!^path\.config:!#&!g' "$LS_SETTINGS_DIR/logstash.yml"; \ + fi; \ +# if the "log4j2.properties" file exists (logstash 5.x), let's empty it out so we get the default: "logging only errors to the console" + if [ -f "$LS_SETTINGS_DIR/log4j2.properties" ]; then \ + cp "$LS_SETTINGS_DIR/log4j2.properties" "$LS_SETTINGS_DIR/log4j2.properties.dist"; \ + truncate --size=0 "$LS_SETTINGS_DIR/log4j2.properties"; \ fi COPY docker-entrypoint.sh / diff --git a/2.0/Dockerfile b/2.0/Dockerfile index 04802ac97..8b3d411ca 100644 --- a/2.0/Dockerfile +++ b/2.0/Dockerfile @@ -40,11 +40,15 @@ ENV PATH /opt/logstash/bin:$PATH # necessary for 5.0+ (overriden via "--path.settings", ignored by < 5.0) ENV LS_SETTINGS_DIR /etc/logstash # comment out some troublesome configuration parameters -# path.log: logs should go to stdout # path.config: No config files found: /etc/logstash/conf.d/* -RUN set -ex \ - && if [ -f "$LS_SETTINGS_DIR/logstash.yml" ]; then \ - sed -ri 's!^(path.log|path.config):!#&!g' "$LS_SETTINGS_DIR/logstash.yml"; \ +RUN set -ex; \ + if [ -f "$LS_SETTINGS_DIR/logstash.yml" ]; then \ + sed -ri 's!^path\.config:!#&!g' "$LS_SETTINGS_DIR/logstash.yml"; \ + fi; \ +# if the "log4j2.properties" file exists (logstash 5.x), let's empty it out so we get the default: "logging only errors to the console" + if [ -f "$LS_SETTINGS_DIR/log4j2.properties" ]; then \ + cp "$LS_SETTINGS_DIR/log4j2.properties" "$LS_SETTINGS_DIR/log4j2.properties.dist"; \ + truncate --size=0 "$LS_SETTINGS_DIR/log4j2.properties"; \ fi COPY docker-entrypoint.sh / diff --git a/2.1/Dockerfile b/2.1/Dockerfile index 2d67e4403..2d58f3f47 100644 --- a/2.1/Dockerfile +++ b/2.1/Dockerfile @@ -40,11 +40,15 @@ ENV PATH /opt/logstash/bin:$PATH # necessary for 5.0+ (overriden via "--path.settings", ignored by < 5.0) ENV LS_SETTINGS_DIR /etc/logstash # comment out some troublesome configuration parameters -# path.log: logs should go to stdout # path.config: No config files found: /etc/logstash/conf.d/* -RUN set -ex \ - && if [ -f "$LS_SETTINGS_DIR/logstash.yml" ]; then \ - sed -ri 's!^(path.log|path.config):!#&!g' "$LS_SETTINGS_DIR/logstash.yml"; \ +RUN set -ex; \ + if [ -f "$LS_SETTINGS_DIR/logstash.yml" ]; then \ + sed -ri 's!^path\.config:!#&!g' "$LS_SETTINGS_DIR/logstash.yml"; \ + fi; \ +# if the "log4j2.properties" file exists (logstash 5.x), let's empty it out so we get the default: "logging only errors to the console" + if [ -f "$LS_SETTINGS_DIR/log4j2.properties" ]; then \ + cp "$LS_SETTINGS_DIR/log4j2.properties" "$LS_SETTINGS_DIR/log4j2.properties.dist"; \ + truncate --size=0 "$LS_SETTINGS_DIR/log4j2.properties"; \ fi COPY docker-entrypoint.sh / diff --git a/2.2/Dockerfile b/2.2/Dockerfile index 5d0d9271e..3e87f8e85 100644 --- a/2.2/Dockerfile +++ b/2.2/Dockerfile @@ -40,11 +40,15 @@ ENV PATH /opt/logstash/bin:$PATH # necessary for 5.0+ (overriden via "--path.settings", ignored by < 5.0) ENV LS_SETTINGS_DIR /etc/logstash # comment out some troublesome configuration parameters -# path.log: logs should go to stdout # path.config: No config files found: /etc/logstash/conf.d/* -RUN set -ex \ - && if [ -f "$LS_SETTINGS_DIR/logstash.yml" ]; then \ - sed -ri 's!^(path.log|path.config):!#&!g' "$LS_SETTINGS_DIR/logstash.yml"; \ +RUN set -ex; \ + if [ -f "$LS_SETTINGS_DIR/logstash.yml" ]; then \ + sed -ri 's!^path\.config:!#&!g' "$LS_SETTINGS_DIR/logstash.yml"; \ + fi; \ +# if the "log4j2.properties" file exists (logstash 5.x), let's empty it out so we get the default: "logging only errors to the console" + if [ -f "$LS_SETTINGS_DIR/log4j2.properties" ]; then \ + cp "$LS_SETTINGS_DIR/log4j2.properties" "$LS_SETTINGS_DIR/log4j2.properties.dist"; \ + truncate --size=0 "$LS_SETTINGS_DIR/log4j2.properties"; \ fi COPY docker-entrypoint.sh / diff --git a/2.3/Dockerfile b/2.3/Dockerfile index f95cd98c3..761c96aa7 100644 --- a/2.3/Dockerfile +++ b/2.3/Dockerfile @@ -40,11 +40,15 @@ ENV PATH /opt/logstash/bin:$PATH # necessary for 5.0+ (overriden via "--path.settings", ignored by < 5.0) ENV LS_SETTINGS_DIR /etc/logstash # comment out some troublesome configuration parameters -# path.log: logs should go to stdout # path.config: No config files found: /etc/logstash/conf.d/* -RUN set -ex \ - && if [ -f "$LS_SETTINGS_DIR/logstash.yml" ]; then \ - sed -ri 's!^(path.log|path.config):!#&!g' "$LS_SETTINGS_DIR/logstash.yml"; \ +RUN set -ex; \ + if [ -f "$LS_SETTINGS_DIR/logstash.yml" ]; then \ + sed -ri 's!^path\.config:!#&!g' "$LS_SETTINGS_DIR/logstash.yml"; \ + fi; \ +# if the "log4j2.properties" file exists (logstash 5.x), let's empty it out so we get the default: "logging only errors to the console" + if [ -f "$LS_SETTINGS_DIR/log4j2.properties" ]; then \ + cp "$LS_SETTINGS_DIR/log4j2.properties" "$LS_SETTINGS_DIR/log4j2.properties.dist"; \ + truncate --size=0 "$LS_SETTINGS_DIR/log4j2.properties"; \ fi COPY docker-entrypoint.sh / diff --git a/2.4/Dockerfile b/2.4/Dockerfile index 5421e64a7..ae29ebab6 100644 --- a/2.4/Dockerfile +++ b/2.4/Dockerfile @@ -40,11 +40,15 @@ ENV PATH /opt/logstash/bin:$PATH # necessary for 5.0+ (overriden via "--path.settings", ignored by < 5.0) ENV LS_SETTINGS_DIR /etc/logstash # comment out some troublesome configuration parameters -# path.log: logs should go to stdout # path.config: No config files found: /etc/logstash/conf.d/* -RUN set -ex \ - && if [ -f "$LS_SETTINGS_DIR/logstash.yml" ]; then \ - sed -ri 's!^(path.log|path.config):!#&!g' "$LS_SETTINGS_DIR/logstash.yml"; \ +RUN set -ex; \ + if [ -f "$LS_SETTINGS_DIR/logstash.yml" ]; then \ + sed -ri 's!^path\.config:!#&!g' "$LS_SETTINGS_DIR/logstash.yml"; \ + fi; \ +# if the "log4j2.properties" file exists (logstash 5.x), let's empty it out so we get the default: "logging only errors to the console" + if [ -f "$LS_SETTINGS_DIR/log4j2.properties" ]; then \ + cp "$LS_SETTINGS_DIR/log4j2.properties" "$LS_SETTINGS_DIR/log4j2.properties.dist"; \ + truncate --size=0 "$LS_SETTINGS_DIR/log4j2.properties"; \ fi COPY docker-entrypoint.sh / diff --git a/5.0/Dockerfile b/5.0/Dockerfile index 9df7d4ec0..b2797e687 100644 --- a/5.0/Dockerfile +++ b/5.0/Dockerfile @@ -40,11 +40,15 @@ ENV PATH /usr/share/logstash/bin:$PATH # necessary for 5.0+ (overriden via "--path.settings", ignored by < 5.0) ENV LS_SETTINGS_DIR /etc/logstash # comment out some troublesome configuration parameters -# path.log: logs should go to stdout # path.config: No config files found: /etc/logstash/conf.d/* -RUN set -ex \ - && if [ -f "$LS_SETTINGS_DIR/logstash.yml" ]; then \ - sed -ri 's!^(path.log|path.config):!#&!g' "$LS_SETTINGS_DIR/logstash.yml"; \ +RUN set -ex; \ + if [ -f "$LS_SETTINGS_DIR/logstash.yml" ]; then \ + sed -ri 's!^path\.config:!#&!g' "$LS_SETTINGS_DIR/logstash.yml"; \ + fi; \ +# if the "log4j2.properties" file exists (logstash 5.x), let's empty it out so we get the default: "logging only errors to the console" + if [ -f "$LS_SETTINGS_DIR/log4j2.properties" ]; then \ + cp "$LS_SETTINGS_DIR/log4j2.properties" "$LS_SETTINGS_DIR/log4j2.properties.dist"; \ + truncate --size=0 "$LS_SETTINGS_DIR/log4j2.properties"; \ fi COPY docker-entrypoint.sh / diff --git a/Dockerfile.template b/Dockerfile.template index 8146c2cd9..e7c997e6f 100644 --- a/Dockerfile.template +++ b/Dockerfile.template @@ -40,11 +40,15 @@ ENV PATH %%LOGSTASH_PATH%%:$PATH # necessary for 5.0+ (overriden via "--path.settings", ignored by < 5.0) ENV LS_SETTINGS_DIR /etc/logstash # comment out some troublesome configuration parameters -# path.log: logs should go to stdout # path.config: No config files found: /etc/logstash/conf.d/* -RUN set -ex \ - && if [ -f "$LS_SETTINGS_DIR/logstash.yml" ]; then \ - sed -ri 's!^(path.log|path.config):!#&!g' "$LS_SETTINGS_DIR/logstash.yml"; \ +RUN set -ex; \ + if [ -f "$LS_SETTINGS_DIR/logstash.yml" ]; then \ + sed -ri 's!^path\.config:!#&!g' "$LS_SETTINGS_DIR/logstash.yml"; \ + fi; \ +# if the "log4j2.properties" file exists (logstash 5.x), let's empty it out so we get the default: "logging only errors to the console" + if [ -f "$LS_SETTINGS_DIR/log4j2.properties" ]; then \ + cp "$LS_SETTINGS_DIR/log4j2.properties" "$LS_SETTINGS_DIR/log4j2.properties.dist"; \ + truncate --size=0 "$LS_SETTINGS_DIR/log4j2.properties"; \ fi COPY docker-entrypoint.sh /