From e4230e61d70065a98ccdbb179f9107a1c4add7f6 Mon Sep 17 00:00:00 2001 From: Tommy Ludwig Date: Thu, 15 Oct 2015 20:30:23 +0900 Subject: [PATCH] Make the name of the log file produced by launch script configurable Previously, the launch script would always use a file named .log to capture the application's console output. This commit adds a variable, LOG_FILENAME, for specifying the file name defaulting to .log. Fixes gh-4194 --- spring-boot-docs/src/main/asciidoc/deployment.adoc | 3 +++ .../org/springframework/boot/loader/tools/launch.script | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/spring-boot-docs/src/main/asciidoc/deployment.adoc b/spring-boot-docs/src/main/asciidoc/deployment.adoc index 6e15fe58c5c..9cb8c1b625c 100644 --- a/spring-boot-docs/src/main/asciidoc/deployment.adoc +++ b/spring-boot-docs/src/main/asciidoc/deployment.adoc @@ -427,6 +427,9 @@ the default behavior in a script or on the command line: |`LOG_FOLDER` |The name of the folder to put log files in (`/var/log` by default). +|`LOG_FILENAME` +|The name of the log file in the `LOG_FOLDER` (`.log` by default). + |`APP_NAME` |The name of the app. If the jar is run from a symlink the script guesses the app name, but if it is not a symlink, or you want to explicitly set the app name this can be diff --git a/spring-boot-tools/spring-boot-loader-tools/src/main/resources/org/springframework/boot/loader/tools/launch.script b/spring-boot-tools/spring-boot-loader-tools/src/main/resources/org/springframework/boot/loader/tools/launch.script index 74f8d5d65cc..d807450ac3f 100755 --- a/spring-boot-tools/spring-boot-loader-tools/src/main/resources/org/springframework/boot/loader/tools/launch.script +++ b/spring-boot-tools/spring-boot-loader-tools/src/main/resources/org/springframework/boot/loader/tools/launch.script @@ -61,7 +61,8 @@ if [[ -z "$identity" ]]; then fi fi - +# Initialize log file name if not provided by the config file +[[ -z "$LOG_FILENAME" ]] && LOG_FILENAME="${identity}.log" # ANSI Colors @@ -91,7 +92,7 @@ if [[ "$identity" == "$init_script" ]] || [[ "$identity" == "$APP_NAME" ]]; then PID_FOLDER="$PID_FOLDER/${identity}" fi pid_file="$PID_FOLDER/${identity}.pid" -log_file="$LOG_FOLDER/${identity}.log" +log_file="$LOG_FOLDER/$LOG_FILENAME" # Determine the user to run as if we are root [[ $(id -u) == "0" ]] && run_user=$(ls -ld "$jarfile" | awk '{print $3}')