Solr logs are a key way to know what’s happening in the system. There are several ways to adjust the default logging configuration.
In addition to the logging options described below, there is a way to configure which request parameters (such as parameters sent as part of queries) are logged with an additional request parameter called
Temporary Logging Settings
You can control the amount of logging output in Solr by using the Admin Web interface. Select the LOGGING link. Note that this page only lets you change settings in the running system and is not saved for the next run. (For more information about the Admin Web interface, see Using the Solr Administration User Interface.)
This part of the Admin Web interface allows you to set the logging level for many different log categories. Fortunately, any categories that are unset will have the logging level of its parent. This makes it possible to change many categories at once by adjusting the logging level of their parent.
When you select Level, you see the following menu:
Directories are shown with their current logging levels. The Log Level Menu floats over these. To set a log level for a particular directory, select it and click the appropriate log level button.
Log levels settings are as follows:
Reports everything but the least important messages.
Reports configuration errors.
Reports everything but normal status.
Reports all warnings.
Reports only the most severe warnings.
Turns off logging.
Removes the previous log setting.
Multiple settings at one time are allowed.
Log level API
There is also a way of sending REST commands to the logging endpoint to do the same. Example:
# Set the root logger to level WARN
curl -s http://localhost:8983/solr/admin/info/logging --data-binary "set=root:WARN&wt=json"
Choosing Log Level at Startup
You can temporarily choose a different logging level as you start Solr. There are two ways:
The first way is to set the
SOLR_LOG_LEVEL environment variable before you start Solr, or place the same variable in
bin/solr.in.cmd. The variable must contain an uppercase string with a supported log level (see above).
The second way is to start Solr with the -v or -q options, see Solr Control Script Reference for details. Examples:
# Start with verbose (DEBUG) looging
bin/solr start -f -v
# Start with quiet (WARN) logging
bin/solr start -f -q
Permanent Logging Settings
Solr uses Log4J version 1.2 for logging which is configured using
server/resources/log4j.properties. Take a moment to inspect the contents of the
log4j.properties file so that you are familiar with its structure. By default, Solr log messages will be written to
When you’re ready to deploy Solr in production, set the variable
SOLR_LOGS_DIR to the location where you want Solr to write log files, such as
/var/solr/logs. You may also want to tweak
log4j.properties. Note that if you installed Solr as a service using the instructions provided in Taking Solr to Production, then see
/var/solr/log4j.properties instead of the default
When starting Solr in the foreground (
-f option), all logs will be sent to the console, in addition to
solr.log. When starting Solr in the background, it will write all
stderr output to a log file in
solr-<port>-console.log, and automatically disable the CONSOLE logger configured in
log4j.properties, having the same effect as if you removed the CONSOLE appender from the rootLogger manually.
log4j.properties the default log rotation size threshold of 4MB is most likely too small for production servers and should be increased to a larger value (such as 100MB or more).
Java Garbage Collection logs are rotated by the JVM when size hits 20M, for a max of 9 generations. Old GC logs are moved to
SOLR_LOGS_DIR/archived. These settings can only be changed by editing the start scripts.
On every startup of Solr, the start script will clean up old logs and rotate the main
solr.log file. If you changed the
log4j.appender.file.MaxBackupIndex setting in
log4j.properties, you also need to change the corresponding setting
-rotate_solr_logs 9 in the start script.
You can disable the automatic log rotation at startup by changing the setting
SOLR_LOG_PRESTART_ROTATION found in
bin/solr.in.cmd to false.
Logging Slow Queries
For high-volume search applications, logging every query can generate a large amount of logs and, depending on the volume, potentially impact performance. If you mine these logs for additional insights into your application, then logging every query request may be useful.
On the other hand, if you’re only concerned about warnings and error messages related to requests, then you can set the log verbosity to WARN. However, this poses a potential problem in that you won’t know if any queries are slow, as slow queries are still logged at the INFO level.
Solr provides a way to set your log verbosity threshold to WARN and be able to set a latency threshold above which a request is considered "slow" and log that request at the WARN level to help you identify slow queries in your application. To enable this behavior, configure the
<slowQueryThresholdMillis> element in the query section of solrconfig.xml:
Any queries that take longer than the specified threshold will be logged as "slow" queries at the WARN level.