From 70e51ab6d3d087ce2330f73e47477c66f367834d Mon Sep 17 00:00:00 2001 From: Ajanthan Date: Wed, 25 Apr 2018 20:07:01 -0700 Subject: [PATCH] Redirecting apm-webapp log to rotatable file (#1119) fix #931 --- apm-dist/bin/webappService.bat | 9 ++++++- apm-dist/bin/webappService.sh | 5 +++- .../src/main/resources/logback-spring.xml | 26 +++++++++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 apm-webapp/src/main/resources/logback-spring.xml diff --git a/apm-dist/bin/webappService.bat b/apm-dist/bin/webappService.bat index 22f182d72..22dd6e917 100644 --- a/apm-dist/bin/webappService.bat +++ b/apm-dist/bin/webappService.bat @@ -20,6 +20,13 @@ setlocal set WEBAPP_PROCESS_TITLE=Skywalking-Webapp set WEBAPP_HOME=%~dp0%.. set JARPATH=%WEBAPP_HOME%\webapp +set WEBAPP_LOG_DIR=%WEBAPP_HOME%\logs + +if exist "%WEBAPP_LOG_DIR%" ( + mkdir "%WEBAPP_LOG_DIR%" +) + +set LOG_FILE_LOCATION=%WEBAPP_LOG_DIR%\webapp.log if defined JAVA_HOME ( set _EXECJAVA="%JAVA_HOME:"=%"\bin\java @@ -30,5 +37,5 @@ if not defined JAVA_HOME ( set _EXECJAVA=java ) -start "%WEBAPP_PROCESS_TITLE%" %_EXECJAVA% -jar %JARPATH%/skywalking-webapp.jar --server.port=8080 --collector.ribbon.listOfServers=127.0.0.1:10800 +start "%WEBAPP_PROCESS_TITLE%" %_EXECJAVA% -jar %JARPATH%/skywalking-webapp.jar --server.port=8080 --collector.ribbon.listOfServers=127.0.0.1:10800 --logging.file=%LOG_FILE_LOCATION% endlocal diff --git a/apm-dist/bin/webappService.sh b/apm-dist/bin/webappService.sh index c915ff251..fdd52c48b 100644 --- a/apm-dist/bin/webappService.sh +++ b/apm-dist/bin/webappService.sh @@ -28,12 +28,15 @@ if [ ! -d "${WEBAPP_HOME}/logs" ]; then mkdir -p "${WEBAPP_LOG_DIR}" fi +LOG_FILE_LOCATION=${WEBAPP_LOG_DIR}/webapp.log + _RUNJAVA=${JAVA_HOME}/bin/java [ -z "$JAVA_HOME" ] && _RUNJAVA=java eval exec "\"$_RUNJAVA\" ${JAVA_OPTS} -jar ${JAR_PATH}/skywalking-webapp.jar \ --server.port=8080 --collector.ribbon.listOfServers=127.0.0.1:10800 \ - 2>${WEBAPP_LOG_DIR}/webapp.log 1> /dev/null &" + --logging.file=${LOG_FILE_LOCATION} \ + 2>${WEBAPP_LOG_DIR}/webapp-console.log 1> /dev/null &" if [ $? -eq 0 ]; then sleep 1 diff --git a/apm-webapp/src/main/resources/logback-spring.xml b/apm-webapp/src/main/resources/logback-spring.xml new file mode 100644 index 000000000..3e017a776 --- /dev/null +++ b/apm-webapp/src/main/resources/logback-spring.xml @@ -0,0 +1,26 @@ + + + + + + + + + + \ No newline at end of file -- GitLab