Solr logging configuration, logging to files

Solr has the below 8 Logging levels
FINEST: Reports everything.
FINE: Reports everything but the least important message.
CONFIG: Reports configuration errors.
INFO: Reports everything but normal status.
WARNING: Reports all warnings.
SEVERE: Reports only the most severe warnings.
OFF: Turns off logging.
UNSET: Removes the previous log setting.

By default, solr prints all the logs to the console. To print the logs to a log file, do the following.

1. Create a file with name logging.properties and put it in Jetty setup (in solr example/ directory), and put the following in the file. We can change the value for .level as we want.

# Default global logging level:
.level = INFO

# Write to a file:
handlers = java.util.logging.FileHandler

# Write log messages in XML format:
# Use java.util.logging.SimpleFormatter to log like Solr logs to the screen by default
java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter

# Log to the current working directory, with log files named solrxxx.log
java.util.logging.FileHandler.pattern = ./logs/solr%u.log

2. Tell Java about the logging.properties file we just created.
Instead of

java -jar start.jar

we will use

java -Djava.util.logging.config.file=logging.properties -jar start.jar

With jetty, we can modify example/etc/jetty.xml so we can start the Jetty server for solr normally without specifying the -D option. We can add the following just before the tag

<Call class="java.lang.System" name="setProperty">
    <Arg>java.util.logging.config.file</Arg>
    <Arg>logging.properties</Arg>
</Call>

With the above configrations, restart the Jetty server for solr, the log should now be logged into files in example/logs/ directory.

Search within Codexpedia

Custom Search

Search the entire web

Custom Search