lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Solr Wiki] Update of "SolrLogging" by ShawnHeisey
Date Fri, 24 May 2013 19:17:18 GMT
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=30&rev2=31

Comment:
added section about intercept jars, other minor edits.

  
  = Solr's Logging Mechanism =
  
- Starting with Solr 1.4, the Solr Code base compiles against the "SLF4J" API.
+ Starting with Solr 1.4, the Solr Code base compiles against the [[http://www.slf4j.org|SLF4J]]
API.
  
  The Solr Admin console has a [[http://localhost:8983/solr/admin/logging.jsp|screen for changing
the logging level globally]].  This is a transient setting good for doing diagnostic work,
but does not persist after restart.
  
  == Solr 4.3 and above ==
  
+ === What changed ===
- These versions do not include any logging jars in the WAR file.  They must be provided separately.
 The Solr example for these versions includes jars (in the jetty lib/ext directory) that set
up SLF4J with a binding to the Apache log4j library.  By changing the jar files, you can easily
switch to an alternate logging mechanism (like logback) or use upgraded versions of the logging
components.
+ These versions do not include any logging jars in the WAR file.  They must be provided separately.
 The Solr example for these versions includes jars (in the jetty lib/ext directory) that set
up SLF4J with a binding to the Apache log4j library.
  
+ === Why did it change? ===
+ The logging setup was changed for increased flexibility.  With older versions, changing
your logging mechanism required either building a special target from the source code or doing
surgery on the WAR file.  Now anyone can change to another logging mechanism or upgrade to
newer component versions simply by changing jar files.
+ 
+ === A note about SLF4J intercept jars ===
+ Some of the third-party software components in Solr do not use the SLF4J library for their
logging, they use one of the other logging frameworks directly.  SLF4J includes various 'intercept'
jars that grab the output of these direct calls and send them through SLF4J so that all your
logs end up handled by the same configuration.  The logging frameworks that must be dealt
with are java.util.logging (JUL), java.commons.logging (JCL), and log4j.
+ 
+ The default SLF4J logging destination for the 4.3 example is log4j, so the example does
not need to intercept calls for that framework.  They will be handled by the real log4j jar.
 It only needs to intercept JUL and JCL, as described above.  This is why the jul-to-slf4j
and jcl-over-slf4j jars are included in the 4.3 example.  If you change your logging framework
from log4j to JUL, then you must remove the intercept jar for JUL and add the intercept jar
for log4j, which is named log4j-over-slf4j.  If you use an entirely different logging mechanism
like logback, then you must have intercepts for all three - JUL, JCL, and log4j.
+ 
+ === Using the example logging setup in containers other than Jetty ===
- To get the same logging setup in e.g. Tomcat as with the example Jetty server, you need
to do the following
+ To get the same logging setup in another container (Tomcat for example) as with the example
Jetty server, you need to do the following
   1. Copy the jars from {{{solr/example/lib/ext}}} into {{{tomcat/lib}}} to setup SLF4J
-  2. Copy the logging config from {{{solr/example/resources/log4j.properties}}} into some
location, e.g. {{{tomcat/lib}}} and edit the file for you preferred log destination
+  1. Copy the logging config from {{{solr/example/resources/log4j.properties}}} into a location
on the classpath.  Usually you can use the same location as the jar files above.  Edit the
configuration file for your preferred log destination.
-  3. Optionally, if you did not place {{{log4j.properties}}} on the classpath, set java
option {{{-Dlog4j.configuration=file:///path/to/log4j.properties}}}
+  1. Optionally, if you did not place {{{log4j.properties}}} on the classpath, set java
option {{{-Dlog4j.configuration=file:///path/to/log4j.properties}}}
  
- If the system cannot find your logging configuration, you may get erros like this:
+ If the system cannot find your logging configuration, you may get errors like this:
  {{{
  log4j:WARN No appenders could be found for logger (org.apache.solr.servlet.SolrDispatchFilter).
  log4j:WARN Please initialize the log4j system properly.
@@ -27, +37 @@

  It might help to start the server with {{{-Dlog4j.debug=true}}} to see more details.
  
  === Switching from Log4J logging back to Java-util logging ===
- If you want to stick to the old-style logging, here's what to do (assuming solr4.3 - note
that SLF4J version may be different for newer versions)
+ If you want to stick to the old-style logging, here's what to do.  This assumes that the
slf4j version is 1.6.6, which comes with [[Solr4.3]].  Newer versions may use a different
slf4j version.  All slf4j components in your classpath must be the same version.
   1. Download slf4j version 1.6.6 (the version used in Solr4.3.x). http://www.slf4j.org/dist/slf4j-1.6.6.zip
-  2. Unpack, and pull out the file slf4j-jdk14-1.6.6.jar (This is the JUL logger impl)
+  2. Unpack the slf4j archive.
   3. Delete these JARs from your lib folder: slf4j-log4j12-1.6.6.jar, jul-to-slf4j-1.6.6.jar,
log4j-1.2.16.jar
   4. Add these JARs to your lib folder (from slf4j zip): slf4j-jdk14-1.6.6.jar, log4j-over-slf4j-1.6.6.jar
   5. Use your old logging.properties

Mime
View raw message