Contents
Solr's Logging Mechanism
Solr 1.4 and Above
Starting with Solr 1.4, the Solr Code base compiles against the "SLF4J" API and provides a runtime jar (slf4j-jdk14-X.Y.Z.jar) that implements SLF4J using JDK standard logging -- so all of the information listed below regarding Solr 1.3 and configuring JDK standard logging still applies by default.
Users who want an alternate logging implementation (log4j, logback etc) will need to repackage the .war file and replace slf4j-jdk14-X.Y.Z.jar with an alternate implementation.
From Solr3.6 there is a build target ant dist-war-excl-slf4j which will automatically package the WAR file with only the slf4j-core JAR and no bindings. Using this war file you can place your slf4j-XXX.jar binding file of choice in your servlet containers lib folder.
More Info: http://www.slf4j.org/
Solr 1.0 to 1.3
Solr uses JDK standard logging, (ie; the java.util.logging.* package; also known as "JUL"), an overview of how that can be configured at the JVM level can be found here...
http://java.sun.com/j2se/1.5.0/docs/guide/logging/overview.html
...but many servlet containers provide alternate log configuration options in their configuration files. You should consult your servlet containers documentation to see what options are available.
The Solr Admin console has a screen for toggling the logging level globally. This is a transient setting good for doing diagnostic work, but does not persist after reboot.
Customizing Logging
With Example Jetty Instance
If you don't know much about JDK containers or servlet containers and want a quick recipe for modifying the logging settings for default Solr example/ setup, see LoggingInDefaultJettySetup.
Using Logback
Here are some details for implementing logback (http://logback.qos.ch/). As you may know, Logback is from the same author as Log4j. It has several enhancements including Filters and Custom Appenders.
1. Get Solr 3.5 http://www.apache.org/dyn/closer.cgi/lucene/solr/3.5.0 and extract the tar/zip file on your system.
Note: $ORIG is your top level directory for Solr.
# cd $ORIG # tar xzvf apache-solr-3.5.0.tgz
2. Copy the solr.war file to a new location
# mkdir -p /tmp/solr # cd ./example/webapps # cp solr.war /tmp/solr # cd /tmp/solr # jar xvf solr.war # rm -f solr.war
3. Remove the slf4j-jdk14-1.6.1.jar file
# cd /tmp/solr # rm -f ./WEB-INF/lib/slf4j-jdk14-1.6.1.jar
4. Copy logback classic files
Get the file: http://logback.qos.ch/dist/logback-1.0.1.tar.gz
# tar xzvf logback-1.0.1.tar.gz # cd logback-1.0.1 # cp logback-classic-1.0.1.jar /tmp/solr/WEB-INF/lib # cp logback-core-1.0.1.jar /tmp/solr/WEB-INF/lib
Note: If you wanted to upgrade SLF4J from 1.6.1 to 1.6.4 you would do the following...
a. Get the SLF4J from http://www.slf4j.org/dist/slf4j-1.6.4.tar.gz
b. Extract the tar into a temporary directory
c. delete the old versions:
# rm /tmp/solr/WEB-INF/lib/jcl-over-slf4j-1.6.1.jar # rm /tmp/solr/WEB-INF/lib/log4j-over-slf4j-1.6.1.jar # rm /tmp/solr/WEB-INF/lib/slf4j-api-1.6.1.jar
d. Copy the new ones
# cp jcl-over-slf4j-1.6.4.jar /tmp/solr/WEB-INF/lib # cp log4j-over-slf4j-1.6.4.jar /tmp/solr/WEB-INF/lib # cp slf4j-api-1.6.4.jar /tmp/solr/WEB-INF/lib
5. Rebuild the war
# cd /tmp/solr # jar cvf solr.war *
6. Copy the war back to your example/webapps directory
# cp solr.war $ORIG/apache-solr-3.5.0/example/webapps
7. Create resources/logback.xml file
# cd $ORIG/apache-solr-3.5.0/example # mkdir resources
copy logback.xml into this directory.
8. Restart Solr 3.5
Example logback.xml.
<configuration debug="true">
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>/var/log/solr.log</file>
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<logger name="org.apache.solr.handler.dataimport.DocBuilder.level" level="SEVERE" additivity="false">
<appender-ref ref="FILE" />
</logger>
<logger name="org.apache.solr.handler.dataimport.ThreadedEntityProcessorWrapper.level" level="SEVERE" additivity="false">
<appender-ref ref="FILE" />
</logger>
<logger name="org.apache.solr.core.SolrCore" level="INFO" additivity="false">
<appender-ref ref="FILE" />
</logger>
<logger name="org.apache.solr" level="INFO" additivity="false">
<appender-ref ref="FILE" />
</logger>
<root level="OFF">
<appender-ref ref="STDOUT" />
</root>
</configuration>