You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-commits@lucene.apache.org by Apache Wiki <wi...@apache.org> on 2012/12/13 07:31:57 UTC

[Solr Wiki] Update of "SolrLogging" by ShawnHeisey

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Solr Wiki" for change notification.

The "SolrLogging" page has been changed by ShawnHeisey:
http://wiki.apache.org/solr/SolrLogging?action=diff&rev1=20&rev2=21

  
  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.
+ <!> From [[Solr3.6]] there is a build target {{{ant dist-war-excl-slf4j}}} which will automatically package the WAR file with only the slf4j-api JAR and no bindings. Using this war file you can place your slf4j-XXX.jar binding file of choice in your servlet container external lib folder.  Note that the slf4j jar(s) that you add must match the version number of the slf4j-api jar file that is contained within the war.  For Solr 3.6, that version is 1.6.1.  For Solr 4.0, it is 1.6.4.
+ 
+ <!> From [[Solr4.1]] there are two build targets related to choosing your own slf4j binding.  These are {{{ant dist-excl-slf4j}}} and {{{ant dist-war-excl-slf4j}}}.  The first target builds the usual dist files in addition to the WAR file, the second just builds the WAR file.  These build targets will package the WAR without any slf4j jars at all, so you must include all relevant slf4j jars in your container external lib directory.
+ 
+ Here are the slf4j jars that are in the WAR file when you build it without one of the special targets mentioned above:
+ 
+  * slf4j-api-1.6.1.jar
+  * slf4j-jdk14-1.6.1.jar
+  * jcl-over-slf4j-1.6.1.jar
+  * log4j-over-slf4j-1.6.1.jar
+ 
+ The first file is the primary slf4j library.  The second is the binding that slf4j uses to send logs to java.util.logging.  Some of Solr's dependent components use other logging methods - jcl and log4j.  The remaining jar files above intercept calls to these other logging methods and inject them into slf4j.
+ 
+ When you change the slf4j binding, you must include the primary library (the -api jar), the binding for the logging method that you wish to use, the jar(s) for that logging method, and relevant "-over-slf4j" jars.  Note that if you choose either jcl or log4j for your binding, you must leave out the matching "-over-slf4j" jar.
  
  More Info: http://www.slf4j.org/
  
@@ -30, +43 @@

  
  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 ==
+ == Using log4j with the Solr 4.1 source distribution ==
+ 
+ Currently Solr 4.1 is not available for easy download because it has not been released yet, so you must obtain a [[NightlyBuilds|nightly version]] or [[HowToContribute#Getting_the_source_code|get it from svn]], then compile it using {{{ant dist-war-excl-slf4j}}} as mentioned in the Solr 4.1 note in the first section above.
+ 
+ Here are the jars you will need to put in your container external lib folder, assuming that you get the 1.7.2 version of slf4j.  The last one comes from the log4j website, not slf4j:
+ 
+  * slf4j-api-1.7.2.jar
+  * slf4j-log4j12-1.7.2.jar
+  * jcl-over-slf4j-1.7.2.jar
+  * log4j-1.2.17.jar
+ 
+ http://www.slf4j.org/download.html
+ http://logging.apache.org/log4j/1.2/
+ 
+ Note that log4j must be configured before it will work. One way to do this is to pass an argument like the following to java:
+ 
+ {{{
+ -Dlog4j.configuration=file:etc/log4j.properties
+ }}}
+ 
+ http://logging.apache.org/log4j/1.2/manual.html#defaultInit
+ 
+ Sample log4j.properties file:
+ {{{
+ #  Logging level
+ log4j.rootLogger=WARN, file
+ 
+ #- Daily rotation, no log cleanup.
+ #log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
+ #log4j.appender.file.DatePattern='.'yyyy-MM-dd
+ 
+ #- size rotation with log cleanup.
+ log4j.appender.file=org.apache.log4j.RollingFileAppender
+ log4j.appender.file.MaxFileSize=4MB
+ log4j.appender.file.MaxBackupIndex=9
+ 
+ #- File to log to and log format
+ log4j.appender.file.File=logs/solr.log
+ log4j.appender.file.layout=org.apache.log4j.PatternLayout
+ log4j.appender.file.layout.ConversionPattern=%-5p - %d{yyyy-MM-dd HH:mm:ss.SSS}; %C; %m\n
+ }}}
+ 
+ == Using Logback with the Solr 3.5 binary distribution ==
  
  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.