mirror of https://github.com/apache/lucene.git
SOLR-9325: solr.log is now written to $SOLR_LOGS_DIR without changing log4j.properties
(cherry picked from commit 33db4de
)
This commit is contained in:
parent
edde433594
commit
bc5e06e34c
|
@ -138,6 +138,8 @@ Bug Fixes
|
|||
* SOLR-9604: Pooled SSL connections were not being re-used (Alan Woodward,
|
||||
Mikhail Khludnev, hossman)
|
||||
|
||||
* SOLR-9325: solr.log is now written to $SOLR_LOGS_DIR without changing log4j.properties (janhoy)
|
||||
|
||||
Optimizations
|
||||
----------------------
|
||||
|
||||
|
|
|
@ -1568,7 +1568,7 @@ function launch_solr() {
|
|||
fi
|
||||
|
||||
SOLR_START_OPTS=('-server' "${JAVA_MEM_OPTS[@]}" "${GC_TUNE[@]}" "${GC_LOG_OPTS[@]}" \
|
||||
"${REMOTE_JMX_OPTS[@]}" "${CLOUD_MODE_OPTS[@]}" $SOLR_LOG_LEVEL_OPT \
|
||||
"${REMOTE_JMX_OPTS[@]}" "${CLOUD_MODE_OPTS[@]}" $SOLR_LOG_LEVEL_OPT -Dsolr.log.dir="$SOLR_LOGS_DIR" \
|
||||
"-Djetty.port=$SOLR_PORT" "-DSTOP.PORT=$stop_port" "-DSTOP.KEY=$STOP_KEY" \
|
||||
"${SOLR_HOST_ARG[@]}" "-Duser.timezone=$SOLR_TIMEZONE" \
|
||||
"-Djetty.home=$SOLR_SERVER_DIR" "-Dsolr.solr.home=$SOLR_HOME" "-Dsolr.install.dir=$SOLR_TIP" \
|
||||
|
@ -1578,7 +1578,21 @@ function launch_solr() {
|
|||
IN_CLOUD_MODE=" in SolrCloud mode"
|
||||
fi
|
||||
|
||||
mkdir -p "$SOLR_LOGS_DIR"
|
||||
mkdir -p "$SOLR_LOGS_DIR" 2>/dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
echo -e "\nERROR: Logs directory $SOLR_LOGS_DIR could not be created. Exiting"
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -w "$SOLR_LOGS_DIR" ]; then
|
||||
echo -e "\nERROR: Logs directory $SOLR_LOGS_DIR is not writable. Exiting"
|
||||
exit 1
|
||||
fi
|
||||
case "$SOLR_LOGS_DIR" in
|
||||
contexts|etc|lib|modules|resources|scripts|solr|solr-webapp)
|
||||
echo -e "\nERROR: Logs directory $SOLR_LOGS_DIR is invalid. Reserved for the system. Exiting"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ "$run_in_foreground" == "true" ]; then
|
||||
exec "$JAVA" "${SOLR_START_OPTS[@]}" $SOLR_ADDL_ARGS -jar start.jar "${SOLR_JETTY_CONFIG[@]}"
|
||||
|
|
|
@ -729,7 +729,13 @@ IF "%STOP_KEY%"=="" set STOP_KEY=solrrocks
|
|||
|
||||
@REM This is quite hacky, but examples rely on a different log4j.properties
|
||||
@REM so that we can write logs for examples to %SOLR_HOME%\..\logs
|
||||
IF [%SOLR_LOGS_DIR%] == [] (
|
||||
set "SOLR_LOGS_DIR=%SOLR_SERVER_DIR%\logs"
|
||||
) ELSE (
|
||||
set SOLR_LOGS_DIR=%SOLR_LOGS_DIR:"=%
|
||||
)
|
||||
set SOLR_LOGS_DIR_QUOTED="%SOLR_LOGS_DIR%"
|
||||
|
||||
set "EXAMPLE_DIR=%SOLR_TIP%\example"
|
||||
set TMP=!SOLR_HOME:%EXAMPLE_DIR%=!
|
||||
IF NOT "%TMP%"=="%SOLR_HOME%" (
|
||||
|
@ -965,13 +971,26 @@ IF NOT "%SOLR_SSL_OPTS%"=="" (
|
|||
set "START_OPTS=%START_OPTS% %SOLR_SSL_OPTS% !SSL_PORT_PROP!"
|
||||
)
|
||||
IF NOT "%SOLR_LOG_LEVEL%"=="" set "START_OPTS=%START_OPTS% -Dsolr.log.level=%SOLR_LOG_LEVEL%"
|
||||
|
||||
set "START_OPTS=%START_OPTS% -Dsolr.log.dir=%SOLR_LOGS_DIR_QUOTED%"
|
||||
IF NOT DEFINED LOG4J_CONFIG set "LOG4J_CONFIG=file:%SOLR_SERVER_DIR%\resources\log4j.properties"
|
||||
|
||||
cd /d "%SOLR_SERVER_DIR%"
|
||||
|
||||
IF NOT EXIST "!SOLR_LOGS_DIR!" (
|
||||
mkdir "!SOLR_LOGS_DIR!"
|
||||
IF NOT EXIST "%SOLR_LOGS_DIR%" (
|
||||
mkdir "%SOLR_LOGS_DIR%"
|
||||
)
|
||||
copy /Y NUL "%SOLR_LOGS_DIR%\.writable" > NUL 2>&1 && set WRITEOK=1
|
||||
IF DEFINED WRITEOK (
|
||||
del "%SOLR_LOGS_DIR%\.writable"
|
||||
) else (
|
||||
echo "ERROR: Logs directory %SOLR_LOGS_DIR% is not writable or could not be created. Exiting"
|
||||
GOTO :eof
|
||||
)
|
||||
echo " contexts etc lib modules resources scripts solr solr-webapp " > "%TEMP%\solr-pattern.txt"
|
||||
findstr /i /C:" %SOLR_LOGS_DIR% " "%TEMP%\solr-pattern.txt" 1>nul
|
||||
if %ERRORLEVEL% == 0 (
|
||||
echo "ERROR: Logs directory %SOLR_LOGS_DIR% is invalid. Reserved for the system. Exiting"
|
||||
GOTO :eof
|
||||
)
|
||||
|
||||
IF NOT EXIST "%SOLR_SERVER_DIR%\tmp" (
|
||||
|
@ -988,13 +1007,13 @@ IF "%FG%"=="1" (
|
|||
REM run solr in the foreground
|
||||
title "Solr-%SOLR_PORT%"
|
||||
echo %SOLR_PORT%>"%SOLR_TIP%"\bin\solr-%SOLR_PORT%.port
|
||||
"%JAVA%" %SERVEROPT% %SOLR_JAVA_MEM% %START_OPTS% %GCLOG_OPT%:"!SOLR_LOGS_DIR!"/solr_gc.log ^
|
||||
"%JAVA%" %SERVEROPT% %SOLR_JAVA_MEM% %START_OPTS% %GCLOG_OPT%:"!SOLR_LOGS_DIR!/solr_gc.log" ^
|
||||
-Dlog4j.configuration="%LOG4J_CONFIG%" -DSTOP.PORT=!STOP_PORT! -DSTOP.KEY=%STOP_KEY% ^
|
||||
-Djetty.port=%SOLR_PORT% -Dsolr.solr.home="%SOLR_HOME%" -Dsolr.install.dir="%SOLR_TIP%" ^
|
||||
-Djetty.home="%SOLR_SERVER_DIR%" -Djava.io.tmpdir="%SOLR_SERVER_DIR%\tmp" -jar start.jar "%SOLR_JETTY_CONFIG%"
|
||||
) ELSE (
|
||||
START /B "Solr-%SOLR_PORT%" /D "%SOLR_SERVER_DIR%" "%JAVA%" %SERVEROPT% %SOLR_JAVA_MEM% %START_OPTS% ^
|
||||
%GCLOG_OPT%:"!SOLR_LOGS_DIR!"/solr_gc.log -Dlog4j.configuration="%LOG4J_CONFIG%" -DSTOP.PORT=!STOP_PORT! ^
|
||||
%GCLOG_OPT%:"!SOLR_LOGS_DIR!/solr_gc.log" -Dlog4j.configuration="%LOG4J_CONFIG%" -DSTOP.PORT=!STOP_PORT! ^
|
||||
-Dsolr.log.muteconsole ^
|
||||
-DSTOP.KEY=%STOP_KEY% -Djetty.port=%SOLR_PORT% -Dsolr.solr.home="%SOLR_HOME%" -Dsolr.install.dir="%SOLR_TIP%" ^
|
||||
-Djetty.home="%SOLR_SERVER_DIR%" -Djava.io.tmpdir="%SOLR_SERVER_DIR%\tmp" -jar start.jar ^
|
||||
|
|
|
@ -31,6 +31,9 @@ REM Changes the logging level. Valid values: ALL, TRACE, DEBUG, INFO, WARN, ERRO
|
|||
REM This is an alternative to changing the rootLogger in log4j.properties
|
||||
REM set SOLR_LOG_LEVEL=INFO
|
||||
|
||||
REM Location where Solr should write logs to. Absolute or relative to solr start dir
|
||||
REM set SOLR_LOGS_DIR=logs
|
||||
|
||||
REM These GC settings have shown to work well for a number of common Solr workloads
|
||||
set GC_TUNE=-XX:NewRatio=3 ^
|
||||
-XX:SurvivorRatio=4 ^
|
||||
|
|
|
@ -96,9 +96,8 @@ SOLR_OPTS="$SOLR_OPTS -Xss256k"
|
|||
# This is an alternative to changing the rootLogger in log4j.properties
|
||||
#SOLR_LOG_LEVEL=INFO
|
||||
|
||||
# Location where Solr should write logs to; should agree with the file appender
|
||||
# settings in server/resources/log4j.properties
|
||||
#SOLR_LOGS_DIR=
|
||||
# Location where Solr should write logs to. Absolute or relative to solr start dir
|
||||
#SOLR_LOGS_DIR=logs
|
||||
|
||||
# Sets the port Solr binds to, default is 8983
|
||||
#SOLR_PORT=8983
|
||||
|
|
|
@ -123,6 +123,7 @@ public class SolrDispatchFilter extends BaseSolrFilter {
|
|||
{
|
||||
log.trace("SolrDispatchFilter.init(): {}", this.getClass().getClassLoader());
|
||||
|
||||
StartupLoggingUtils.checkLogDir();
|
||||
logWelcomeBanner();
|
||||
String muteConsole = System.getProperty(SOLR_LOG_MUTECONSOLE);
|
||||
if (muteConsole != null && !Arrays.asList("false","0","off","no").contains(muteConsole.toLowerCase(Locale.ROOT))) {
|
||||
|
|
|
@ -40,6 +40,15 @@ final class StartupLoggingUtils {
|
|||
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||
private final static StaticLoggerBinder binder = StaticLoggerBinder.getSingleton();
|
||||
|
||||
/**
|
||||
* Checks whether mandatory log dir is given
|
||||
*/
|
||||
static void checkLogDir() {
|
||||
if (System.getProperty("solr.log.dir") == null) {
|
||||
log.error("Missing Java Option solr.log.dir. Logging may be missing or incomplete.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables all log4j ConsoleAppender's by modifying log4j configuration dynamically.
|
||||
* Must only be used during early startup
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Default Solr log4j config
|
||||
# rootLogger log level may be programmatically overridden by -Dsolr.log.level
|
||||
solr.log=logs
|
||||
solr.log=${solr.log.dir}
|
||||
log4j.rootLogger=INFO, file, CONSOLE
|
||||
|
||||
# Console appender will be programmatically disabled when Solr is started with option -Dsolr.log.muteconsole
|
||||
|
|
Loading…
Reference in New Issue