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:
|FINE||Reports everything but the least important messages.|
|CONFIG||Reports configuration errors.|
|INFO||Reports everything but normal status.|
|WARN||Reports all warnings.|
|SEVERE||Reports only the most severe warnings.|
|OFF||Turns off logging.|
|UNSET||Removes the previous log setting.|
Multiple settings at one time are allowed.
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"
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 2.11.0 for logging which is configured using
server/resources/log4j2.xml. Take a moment to inspect the contents of the
log4j2.xml 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
log4j2.xml. Note that if you installed Solr as a service using the instructions provided in Taking Solr to Production, then see
/var/solr/log4j2.xml 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
log4j2.xml, having the same effect as if you removed the CONSOLE appender from the rootLogger manually.
log4j2.xml if the default log rotation size threshold of 32MB is too small for production servers then you should increase it to a larger value (such as 100MB or more).
<SizeBasedTriggeringPolicy size="100 MB"/>
Java Garbage Collection logs are rotated by the JVM when size hits 20M, for a max of 9 generations.
On every startup or restart of Solr, log4j2 performs log rotation. If you choose to use another log framework that does not support rotation on startup, you may enable
bin/solr.in.cmd to let the start script rotate the logs on startup.
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
Any queries that take longer than the specified threshold will be logged as "slow" queries at the WARN level. The log file under which you can find all these queries is called
solr_slow_requests.log and will be found in your
SOLR_LOGS_DIR (see Permanent Logging Settings for more about defining log locations).