After the base installation of solr under tomcat 7 is now the step to configure seperate logging for solr. Fist step is to create a directory for the log file:
mkdir /var/log/solr
chown tomcat7:adm /var/log/solr
Now delete the following files in the extracted war lib folder (/usr/share/solr/war/WEB-INF/lib)
- jcl-over-slf4j-1.6.4.jar
- log4j-over-slf4j-1.6.4 .jar
- slf4j-api-1.6.4.jar
- slf4j-jdk14-1.6.4.jar
Copy the following files into this folder
- slf4j-api-1.6.5.jar
- slf4j-log4j12-1.6.5.jar
- log4j-1.2.16.jar
Create a classes folder inside the WEB-INF folder
mkdir /usr/share/solr/war/WEB-INF/classes
Create a log4j.properties in this folder with the following sample content
log4j.rootLogger=WARN, solrLog
log4j.appender.solrLog=org.apache.log4j.DailyRollingFileAppender
log4j.appender.solrLog.File=/var/log/solr/solr.log
log4j.appender.solrLog.Append=true
log4j.appender.solrLog.Encoding=UTF-8
log4j.appender.solrLog.DatePattern=’-‘yyyy-MM-dd
log4j.appender.solrLog.layout=org.apache.log4j.PatternLayout
log4j.appender.solrLog.layout.ConversionPattern=%d [%t] %-5p %c – %m%n
log4j.logger.org.apache.solr=INFO
Change folder and file rights to give the tomcat instance user full access
chown -R tomcat7:adm /usr/share/solr/war
Restart tomcat
service tomcat7 restart
Now you will find a solr.log inside/var/log/solr/