You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2013/07/02 15:34:13 UTC
svn commit: r1498936 - in /lucene/dev/trunk/solr: ./
core/src/java/org/apache/solr/update/
core/src/test-files/solr/collection1/conf/
core/src/test/org/apache/solr/core/ example/alt-configs/hdfs/
example/resources/ example/solr/collection1/conf/
Author: rmuir
Date: Tue Jul 2 13:34:12 2013
New Revision: 1498936
URL: http://svn.apache.org/r1498936
Log:
SOLR-4977: Add option to send infostream to the logging system
Added:
lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/LoggingInfoStream.java (with props)
lucene/dev/trunk/solr/core/src/test-files/solr/collection1/conf/solrconfig-infostream-logging.xml (with props)
lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/TestInfoStreamLogging.java (with props)
Modified:
lucene/dev/trunk/solr/CHANGES.txt
lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/SolrIndexConfig.java
lucene/dev/trunk/solr/example/alt-configs/hdfs/solrconfig.xml
lucene/dev/trunk/solr/example/resources/log4j.properties
lucene/dev/trunk/solr/example/solr/collection1/conf/solrconfig.xml
Modified: lucene/dev/trunk/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=1498936&r1=1498935&r2=1498936&view=diff
==============================================================================
--- lucene/dev/trunk/solr/CHANGES.txt (original)
+++ lucene/dev/trunk/solr/CHANGES.txt Tue Jul 2 13:34:12 2013
@@ -145,6 +145,9 @@ New Features
* SOLR-4655: Add option to have Overseer assign generic node names so that
new addresses can host shards without naming confusion. (Mark Miller, Anshum Gupta)
+* SOLR-4977: Add option to send IndexWriter's infostream to the logging system.
+ (Ryan Ernst via Robert Muir)
+
Bug Fixes
----------------------
Added: lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/LoggingInfoStream.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/LoggingInfoStream.java?rev=1498936&view=auto
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/LoggingInfoStream.java (added)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/LoggingInfoStream.java Tue Jul 2 13:34:12 2013
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.update;
+
+import org.apache.lucene.util.InfoStream;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+
+/**
+ * An {@link InfoStream} implementation which passes messages on to Solr's logging.
+ */
+public class LoggingInfoStream extends InfoStream {
+ public static final Logger log = LoggerFactory.getLogger(LoggingInfoStream.class);
+
+ @Override
+ public void message(String component, String message) {
+ log.info("[" + component + "][" + Thread.currentThread().getName() + "]: " + message);
+ }
+
+ @Override
+ public boolean isEnabled(String component) {
+ // ignore testpoints so this can be used with tests without flooding logs with verbose messages
+ return !"TP".equals(component) && log.isInfoEnabled();
+ }
+
+ @Override
+ public void close() throws IOException {}
+}
Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/SolrIndexConfig.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/SolrIndexConfig.java?rev=1498936&r1=1498935&r2=1498936&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/SolrIndexConfig.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/SolrIndexConfig.java Tue Jul 2 13:34:12 2013
@@ -153,8 +153,12 @@ public class SolrIndexConfig {
boolean infoStreamEnabled = solrConfig.getBool(prefix + "/infoStream", false);
if(infoStreamEnabled) {
String infoStreamFile = solrConfig.get(prefix + "/infoStream/@file", null);
- if (infoStreamFile != null) {
- log.info("IndexWriter infoStream debug log is enabled: " + infoStreamFile);
+ if (infoStreamFile == null) {
+ log.info("IndexWriter infoStream solr logging is enabled");
+ infoStream = new LoggingInfoStream();
+ } else {
+ log.warn("IndexWriter infoStream file log is enabled: " + infoStreamFile +
+ "\nThis feature is deprecated. Remove @file from <infoStream> to output messages to solr's logfile");
File f = new File(infoStreamFile);
File parent = f.getParentFile();
if (parent != null) parent.mkdirs();
Added: lucene/dev/trunk/solr/core/src/test-files/solr/collection1/conf/solrconfig-infostream-logging.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test-files/solr/collection1/conf/solrconfig-infostream-logging.xml?rev=1498936&view=auto
==============================================================================
--- lucene/dev/trunk/solr/core/src/test-files/solr/collection1/conf/solrconfig-infostream-logging.xml (added)
+++ lucene/dev/trunk/solr/core/src/test-files/solr/collection1/conf/solrconfig-infostream-logging.xml Tue Jul 2 13:34:12 2013
@@ -0,0 +1,27 @@
+<?xml version="1.0" ?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<config>
+ <dataDir>${solr.data.dir:}</dataDir>
+
+ <luceneMatchVersion>${tests.luceneMatchVersion:LUCENE_CURRENT}</luceneMatchVersion>
+
+ <indexConfig>
+ <infoStream>true</infoStream>
+ </indexConfig>
+</config>
Added: lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/TestInfoStreamLogging.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/TestInfoStreamLogging.java?rev=1498936&view=auto
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/TestInfoStreamLogging.java (added)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/TestInfoStreamLogging.java Tue Jul 2 13:34:12 2013
@@ -0,0 +1,38 @@
+package org.apache.solr.core;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.lucene.index.IndexWriterConfig;
+import org.apache.lucene.util.PrintStreamInfoStream;
+import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.update.LoggingInfoStream;
+import org.junit.BeforeClass;
+
+public class TestInfoStreamLogging extends SolrTestCaseJ4 {
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig-infostream-logging.xml","schema.xml");
+ }
+
+ public void testIndexConfig() throws Exception {
+ IndexWriterConfig iwc = solrConfig.indexConfig.toIndexWriterConfig(h.getCore().getLatestSchema());
+
+ assertTrue(iwc.getInfoStream() instanceof LoggingInfoStream);
+ }
+}
Modified: lucene/dev/trunk/solr/example/alt-configs/hdfs/solrconfig.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/example/alt-configs/hdfs/solrconfig.xml?rev=1498936&r1=1498935&r2=1498936&view=diff
==============================================================================
--- lucene/dev/trunk/solr/example/alt-configs/hdfs/solrconfig.xml (original)
+++ lucene/dev/trunk/solr/example/alt-configs/hdfs/solrconfig.xml Tue Jul 2 13:34:12 2013
@@ -298,10 +298,10 @@
To aid in advanced debugging, Lucene provides an "InfoStream"
of detailed information when indexing.
- Setting The value to true will instruct the underlying Lucene
- IndexWriter to write its debugging info the specified file
+ Setting the value to true will instruct the underlying Lucene
+ IndexWriter to write its info stream to solr's log.
-->
- <!-- <infoStream file="INFOSTREAM.txt">false</infoStream> -->
+ <!-- <infoStream>false</infoStream> -->
</indexConfig>
Modified: lucene/dev/trunk/solr/example/resources/log4j.properties
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/example/resources/log4j.properties?rev=1498936&r1=1498935&r2=1498936&view=diff
==============================================================================
--- lucene/dev/trunk/solr/example/resources/log4j.properties (original)
+++ lucene/dev/trunk/solr/example/resources/log4j.properties Tue Jul 2 13:34:12 2013
@@ -19,3 +19,6 @@ log4j.appender.file.layout.ConversionPat
log4j.logger.org.apache.zookeeper=WARN
log4j.logger.org.apache.hadoop=WARN
+
+# set to INFO to enable infostream log messages
+log4j.logger.org.apache.solr.update.LoggingInfoStream=OFF
Modified: lucene/dev/trunk/solr/example/solr/collection1/conf/solrconfig.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/example/solr/collection1/conf/solrconfig.xml?rev=1498936&r1=1498935&r2=1498936&view=diff
==============================================================================
--- lucene/dev/trunk/solr/example/solr/collection1/conf/solrconfig.xml (original)
+++ lucene/dev/trunk/solr/example/solr/collection1/conf/solrconfig.xml Tue Jul 2 13:34:12 2013
@@ -304,10 +304,11 @@
To aid in advanced debugging, Lucene provides an "InfoStream"
of detailed information when indexing.
- Setting The value to true will instruct the underlying Lucene
- IndexWriter to write its debugging info the specified file
+ Setting the value to true will instruct the underlying Lucene
+ IndexWriter to write its info stream to solr's log. By default,
+ this is enabled here, and controlled through log4j.properties.
-->
- <!-- <infoStream file="INFOSTREAM.txt">false</infoStream> -->
+ <infoStream>true</infoStream>
</indexConfig>