Return-Path: X-Original-To: apmail-lucene-commits-archive@www.apache.org Delivered-To: apmail-lucene-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id CA306DD82 for ; Fri, 24 May 2013 19:17:41 +0000 (UTC) Received: (qmail 83563 invoked by uid 500); 24 May 2013 19:17:41 -0000 Mailing-List: contact commits-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@lucene.apache.org Delivered-To: mailing list commits@lucene.apache.org Received: (qmail 83540 invoked by uid 99); 24 May 2013 19:17:40 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 24 May 2013 19:17:40 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.131] (HELO eos.apache.org) (140.211.11.131) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 24 May 2013 19:17:39 +0000 Received: from eos.apache.org (localhost [127.0.0.1]) by eos.apache.org (Postfix) with ESMTP id 0DC0753E; Fri, 24 May 2013 19:17:19 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: Apache Wiki To: Apache Wiki Date: Fri, 24 May 2013 19:17:18 -0000 Message-ID: <20130524191718.52068.54933@eos.apache.org> Subject: =?utf-8?q?=5BSolr_Wiki=5D_Update_of_=22SolrLogging=22_by_ShawnHeisey?= Auto-Submitted: auto-generated X-Virus-Checked: Checked by ClamAV on apache.org Dear Wiki user, You have subscribed to a wiki page or wiki category on "Solr Wiki" for chan= ge notification. The "SolrLogging" page has been changed by ShawnHeisey: http://wiki.apache.org/solr/SolrLogging?action=3Ddiff&rev1=3D30&rev2=3D31 Comment: added section about intercept jars, other minor edits. = =3D Solr's Logging Mechanism =3D = - Starting with Solr 1.4, the Solr Code base compiles against the "SLF4J" A= PI. + 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.j= sp|screen for changing the logging level globally]]. This is a transient s= etting good for doing diagnostic work, but does not persist after restart. = =3D=3D Solr 4.3 and above =3D=3D = + =3D=3D=3D What changed =3D=3D=3D - These versions do not include any logging jars in the WAR file. They mus= t be provided separately. The Solr example for these versions includes jar= s (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 t= he logging components. + These versions do not include any logging jars in the WAR file. They mus= t be provided separately. The Solr example for these versions includes jar= s (in the jetty lib/ext directory) that set up SLF4J with a binding to the = Apache log4j library. = + =3D=3D=3D Why did it change? =3D=3D=3D + The logging setup was changed for increased flexibility. With older vers= ions, changing your logging mechanism required either building a special ta= rget 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. + = + =3D=3D=3D A note about SLF4J intercept jars =3D=3D=3D + 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 dir= ectly. SLF4J includes various 'intercept' jars that grab the output of the= se direct calls and send them through SLF4J so that all your logs end up ha= ndled 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 th= e example does not need to intercept calls for that framework. They will b= e handled by the real log4j jar. It only needs to intercept JUL and JCL, a= s described above. This is why the jul-to-slf4j and jcl-over-slf4j jars ar= e included in the 4.3 example. If you change your logging framework from l= og4j to JUL, then you must remove the intercept jar for JUL and add the int= ercept jar for log4j, which is named log4j-over-slf4j. If you use an entir= ely different logging mechanism like logback, then you must have intercepts= for all three - JUL, JCL, and log4j. + = + =3D=3D=3D Using the example logging setup in containers other than Jetty = =3D=3D=3D - To get the same logging setup in e.g. Tomcat as with the example Jetty se= rver, you need to do the following + To get the same logging setup in another container (Tomcat for example) a= s with the example Jetty server, you need to do the following 1. Copy the jars from {{{solr/example/lib/ext}}} into {{{tomcat/lib}}} t= o setup SLF4J - 2. Copy the logging config from {{{solr/example/resources/log4j.properti= es}}} into some location, e.g. {{{tomcat/lib}}} and edit the file for you p= referred log destination + 1. Copy the logging config from {{{solr/example/resources/log4j.properti= es}}} into a location on the classpath. Usually you can use the same locat= ion as the jar files above. Edit the configuration file for your preferred= log destination. - 3. Optionally, if you did not place {{{log4j.properties}}}=C2=A0on the c= lasspath, set java option {{{-Dlog4j.configuration=3Dfile:///path/to/log4j.= properties}}} + 1. Optionally, if you did not place {{{log4j.properties}}}=C2=A0on the c= lasspath, set java option {{{-Dlog4j.configuration=3Dfile:///path/to/log4j.= properties}}} = - If the system cannot find your logging configuration, you may get erros l= ike 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.servle= t.SolrDispatchFilter). log4j:WARN Please initialize the log4j system properly. @@ -27, +37 @@ It might help to start the server with {{{-Dlog4j.debug=3Dtrue}}} to see = more details. = =3D=3D=3D Switching from Log4J logging back to Java-util logging =3D=3D= =3D - If you want to stick to the old-style logging, here's what to do (assumin= g 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 a= ssumes that the slf4j version is 1.6.6, which comes with [[Solr4.3]]. Newe= r 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