Configuring Solr 1.4 logging with Log4J in Tomcat

January 6, 2010 at 9:15 pm | Posted in Java, Search, Software Development | 2 Comments
Tags: , , ,

Solr 1.4 logging is based on the “SLF4J” API. To configure Solr to use Log4J as standard logging implementation deploy the Solr web application to your Tomcat. Once the Solr web application got started add the libraries “slf4j-log4j12-1.5.5.jar” and “log4j-1.2.15.jar” to $CATALINA_HOME/webapps/solr/WEB-INF/lib. Delete the library “slf4j-jdk14-1.5.5.jar” from $CATALINA_HOME/webapps/solr/WEB-INF/lib.

Create the directory $CATALINA_HOME/webapps/solr/WEB-INF/classes and add the file log4j.properties. The file should hold your Log4J configuration. Here’s an example using a rolling log file:

log4j.rootLogger=ERROR, logfile

log4j.appender.logfile=org.apache.log4j.DailyRollingFileAppender
log4j.appender.logfile.File=${catalina.home}/logs/solr.log

log4j.appender.logfile.DatePattern='.'yyyy-MM-dd
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
log4j.appender.logfile.layout.ConversionPattern=%d %p [%c{3}] - [%t] - %X{ip}: %m%n

Alternatively, you can prepare your Solr web application WAR file to reflect the steps mentioned above. The Solr logging page (http://<host&gt;:<port>/solr/admin/logging) that comes with the web app will not reflect these changes. It only works for JDK logging that we just configured not to be used anymore. The Tomcat instance has to be restarted to reflect the changes.

About these ads

2 Comments »

RSS feed for comments on this post. TrackBack URI

  1. There is a nice overview of solr logging at http://www.lucidimagination.com/search/document/CDRG_ch09_9.4

  2. [...] サクっといかなくてウジウジしていたら↓このブログを見つけました。 http://globalgateway.wordpress.com/2010/01/06/configuring-solr-1-4-logging-with-log4j-in-tomcat/ ドンピシャ。ありがとう。 でも、Thanks!ってコメントを残そうとしたら、 [...]


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com. | The Pool Theme.
Entries and comments feeds.

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: