Solr:如何关闭日志记录
好的,我对 Solr 感到兴奋,但我似乎无法弄清楚如何降低日志记录级别,以便当我进行大量的进口运行。
我什至不确定它使用的是哪个日志框架(因为,你知道,java.util.logging、log4j 和 commons-logging < em>还不够,我们需要添加slf4j!)好吧,抱歉,不得不让这个小抱怨溜走。 :-)
所以我配置了 src/main/resources/log4j.properties:
log4j.rootLogger=WARN, console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.conversionPattern=%5p [%t] (%F:%L) - %m%n
org.apache.solr.core=WARN
org.apache.solr.update.processor=WARN
然后为了更好的衡量,我配置了 src/main/resources/logging.properties :
.level = WARNING
com.gwtstore.level=ALL
com.appgravity.level=ALL
org.apache.solr.core.level=WARNING
org.apache.solr.update.processor.level=WARNING
但不知何故,我仍然看到大量以下内容:
INFO: {add=[-7757828706308755634]} 0 0
Feb 21, 2011 6:12:23 PM org.apache.solr.core.SolrCore execute
INFO: [] webapp=null path=/update params={} status=0 QTime=0
这是我的类路径:
src/test/resources
src/test/java
src/main/resources
src/main/java
idea_rt.jar
junit-rt.jar
deploy.jar
dt.jar
javaws.jar
jce.jar
jconsole.jar
management-agent.jar
plugin.jar
sa-jdi.jar
alt-rt.jar
charsets.jar
classes.jar
jsse.jar
ui.jar
apple_provider.jar
dnsns.jar
localedata.jar
sunjce_provider.jar
sunpkcs11.jar
test-classes
classes
junit-4.8.2.jar
gwt-user-2.1.1.jar
gwt-servlet-2.1.1.jar
servlet-api-2.5.jar
weld-servlet-1.1.0.Final.jar
hibernate-core-3.6.0.Final.jar
antlr-2.7.6.jar
commons-collections-3.2.1.jar
dom4j-1.6.1.jar
hibernate-commons-annotations-3.2.0.Final.jar
slf4j-api-1.6.0.jar
hibernate-jpa-2.0-api-1.0.0.Final.jar
jta-1.1.jar
hibernate-entitymanager-3.6.0.Final.jar
javassist-3.12.0.GA.jar
hibernate-c3p0-3.3.1.GA.jar
c3p0-0.9.1.jar
hibernate-validator-4.1.0.Final.jar
validation-api-1.0.0.GA.jar
cglib-nodep-2.2.jar
javax.inject-1.jar
cdi-api-1.0.jar
jboss-interceptor-api-1.1.jar
jsr250-api-1.0.jar
lucene-core-2.9.1.jar
lucene-snowball-2.9.1.jar
mongo-java-driver-2.4.jar
mysql-connector-java-5.1.6.jar
protobuf-java-2.2.0.jar
proxytoys-1.0.jar
quartz-1.8.4.jar
commons-lang-2.5.jar
commons-httpclient-3.1.jar
commons-logging-1.0.4.jar
commons-codec-1.2.jar
nekohtml-1.9.7.jar
xercesImpl-2.8.1.jar
xml-apis-1.3.03.jar
gwtquickstarter.jar
solr-solrj-1.4.1.jar
commons-io-1.4.jar
commons-fileupload-1.2.1.jar
wstx-asl-3.2.7.jar
stax-api-1.0.1.jar
geronimo-stax-api_1.0_spec-1.0.1.jar
solr-core-1.4.1.jar
lucene-analyzers-2.9.3.jar
lucene-highlighter-2.9.3.jar
lucene-memory-2.9.3.jar
lucene-queries-2.9.3.jar
lucene-misc-2.9.3.jar
lucene-spellchecker-2.9.3.jar
solr-commons-csv-1.4.1.jar
wstx-asl-3.2.7.jar
morphia-0.98s10.jar
androidmarketapi-0.5.jar
openid4java-0.9.5.jar
OK, so I'm thrilled with Solr, but I can't seem to figure out how to turn down the logging level so that it will actually run acceptably fast when I do a huge import run.
I'm not even sure which logging framework it's using (because, you know, java.util.logging, log4j and commons-logging weren't enough, we needed to add slf4j to the mix!) OK sorry, had to let that minor rant slip. :-)
So I have src/main/resources/log4j.properties
configured with:
log4j.rootLogger=WARN, console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.conversionPattern=%5p [%t] (%F:%L) - %m%n
org.apache.solr.core=WARN
org.apache.solr.update.processor=WARN
And then for good measure I have src/main/resources/logging.properties
configured with:
.level = WARNING
com.gwtstore.level=ALL
com.appgravity.level=ALL
org.apache.solr.core.level=WARNING
org.apache.solr.update.processor.level=WARNING
And yet somehow, I am still seeing tons of the following:
INFO: {add=[-7757828706308755634]} 0 0
Feb 21, 2011 6:12:23 PM org.apache.solr.core.SolrCore execute
INFO: [] webapp=null path=/update params={} status=0 QTime=0
Here's my classpath:
src/test/resources
src/test/java
src/main/resources
src/main/java
idea_rt.jar
junit-rt.jar
deploy.jar
dt.jar
javaws.jar
jce.jar
jconsole.jar
management-agent.jar
plugin.jar
sa-jdi.jar
alt-rt.jar
charsets.jar
classes.jar
jsse.jar
ui.jar
apple_provider.jar
dnsns.jar
localedata.jar
sunjce_provider.jar
sunpkcs11.jar
test-classes
classes
junit-4.8.2.jar
gwt-user-2.1.1.jar
gwt-servlet-2.1.1.jar
servlet-api-2.5.jar
weld-servlet-1.1.0.Final.jar
hibernate-core-3.6.0.Final.jar
antlr-2.7.6.jar
commons-collections-3.2.1.jar
dom4j-1.6.1.jar
hibernate-commons-annotations-3.2.0.Final.jar
slf4j-api-1.6.0.jar
hibernate-jpa-2.0-api-1.0.0.Final.jar
jta-1.1.jar
hibernate-entitymanager-3.6.0.Final.jar
javassist-3.12.0.GA.jar
hibernate-c3p0-3.3.1.GA.jar
c3p0-0.9.1.jar
hibernate-validator-4.1.0.Final.jar
validation-api-1.0.0.GA.jar
cglib-nodep-2.2.jar
javax.inject-1.jar
cdi-api-1.0.jar
jboss-interceptor-api-1.1.jar
jsr250-api-1.0.jar
lucene-core-2.9.1.jar
lucene-snowball-2.9.1.jar
mongo-java-driver-2.4.jar
mysql-connector-java-5.1.6.jar
protobuf-java-2.2.0.jar
proxytoys-1.0.jar
quartz-1.8.4.jar
commons-lang-2.5.jar
commons-httpclient-3.1.jar
commons-logging-1.0.4.jar
commons-codec-1.2.jar
nekohtml-1.9.7.jar
xercesImpl-2.8.1.jar
xml-apis-1.3.03.jar
gwtquickstarter.jar
solr-solrj-1.4.1.jar
commons-io-1.4.jar
commons-fileupload-1.2.1.jar
wstx-asl-3.2.7.jar
stax-api-1.0.1.jar
geronimo-stax-api_1.0_spec-1.0.1.jar
solr-core-1.4.1.jar
lucene-analyzers-2.9.3.jar
lucene-highlighter-2.9.3.jar
lucene-memory-2.9.3.jar
lucene-queries-2.9.3.jar
lucene-misc-2.9.3.jar
lucene-spellchecker-2.9.3.jar
solr-commons-csv-1.4.1.jar
wstx-asl-3.2.7.jar
morphia-0.98s10.jar
androidmarketapi-0.5.jar
openid4java-0.9.5.jar
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
您需要确保日志记录属性文件部署到
.../yourWebapp/WEB-INF/classes/log4j.properties
。如果存在
.../yourWebapp/WEB-INF/classes/log4j.xml
文件,这将覆盖属性文件。Log4j 配置文件的位置也可以由系统属性覆盖。
有关 Log4j 如何获取其配置的更多信息,请参阅本节 Log4j 简介。
You need to make sure that the logging properties file is deployed to
.../yourWebapp/WEB-INF/classes/log4j.properties
.If there is a
.../yourWebapp/WEB-INF/classes/log4j.xml
file, this will override the properties file.The location of the Log4j configuration file can also be overridden by system properties.
For more information on how Log4j gets its configuration, look at this section of the Log4j introduction.
如果您只是想从 Solr 服务器完全关闭日志记录,只需访问 http://(YOUR -IP):8080/solr/admin 并导航到顶部列表中显示的日志记录选项。
在该页面上,您可以找到为 Solr 安装定义的各种日志记录级别的详细表格。要么更改其父记录器,使它们使用您在应用程序中使用的记录器,要么完全关闭它们。
希望这就是您正在寻找的。
谢谢
If you are just looking to turn off logging completely from the Solr server , just visit http://(YOUR-IP):8080/solr/admin and navigate to the logging option seen on top list.
On that page , you could find the detailed table for the various logging levels defined for your Solr installation. Either change their parent logger to make them use the logger you are using in your application or turn them off entirely.
Hope this is what you were looking for.
Thanks
以下链接讨论如何正确配置 Solr 日志记录。
http://lucidworks.lucidimagination.com/display/solr/Configuring+Logging
如果您想临时更改日志记录,可以从 Solr 管理页面完成。要永久进行更改,您需要将 JDK 日志记录属性文件添加到 Solr Web 应用程序。
步骤
即_%TOMCAT_INSTALL_DIR%/webapps/solr/WEB-INF/classes/logging.properties_
Following link discusses how to configure Solr logging properly.
http://lucidworks.lucidimagination.com/display/solr/Configuring+Logging
If you want to make changes to logging temporarily, then it can done from the Solr admin page. For making changes permanently you will need to add a JDK logging properties file to Solr web application.
For tomcat following are the steps
i.e. _%TOMCAT_INSTALL_DIR%/webapps/solr/WEB-INF/classes/logging.properties_
在为 SOLR 的 log4j 完成此操作后,我可以告诉你这很痛苦。 Log4j 不能很好地与 SOLR 一起使用。无论如何,这就是我为使 SOLR 与 slf4j 和 log4j 一起工作所做的工作。如果有更简单的方法 - 很棒 - 就去做吧。
在 solr/lib 中
确定版本与 slf4j-api 匹配-???
)
添加 log4j.xml
Having done this for log4j for SOLR I can tell you it was painful. Log4j doesn't work well with SOLR out the box. Anyway, here is what I did to make SOLR work with slf4j and log4j. If there is an easier way - awesome - do it.
In solr/lib
sure versions match to slf4j-api-???
)
in resources in your webapp add your log4j.xml
经过长时间尝试将“WARNING”一词放置在无数文件中,看起来我终于成功地减慢了 Tomcat Solr 日志记录的速度。这对你的情况/环境有何用处完全超出了我的范围,因为我的大脑现在充满了 JAVA 配置。不管怎样,我还是把它写下来,希望能避免将来有人遭受痛苦。
我可能已经完全禁用了一些日志记录,因此您可能需要在调试时(或例如在开发服务器上)撤消我将在此处描述的内容。
在您的配置文件夹中创建一个名为
logging.properties
的文件,例如在/etc/tomcat...
中(如果该文件尚不存在)。如果
logging.properties
已存在,请注释掉所有内容。不过,如果您需要一些日志记录,您可以选择不注释掉其他行。将以下内容附加/插入到
logging.properties
:在您的
$CATALINA_HOME/ 中创建一个名为
文件夹(如果尚不存在)。 (setenv.sh
的文件bin$CATALINA_HOME
在哪里?通常在/usr/share/tomcat...
中,但输入ps -ef | ps -ef | ps -ef | ps -ef | ps -ef | ps -ef | grep tomcat
并在输出中寻找字符串
catalina.home
或类似的内容以确保确定。)将以下内容附加/插入到
setenv.sh
:重新启动 Tomcat(例如
/etc/init.d/tomcat...restart
,取决于您的操作系统)(替换
tomcat...< /code> 与您的 Tomcat 实际版本)
After long trials of placing the word
WARNING
in infinitely many files, it looks like I've finally managed to slow down Tomcat Solr logging. How would that be useful for your situation/environment is completely beyond me, since my brain is full of JAVA configs as of now. I'm writing it down anyway, with the hope of preventing some pain for someone in the future.I may have completely disabled some logging along the way, so you may need to undo what I'll be describing here when debugging (or e.g. on the development server).
Create a file named
logging.properties
in your config folder, e.g. in/etc/tomcat...
if it doesn't already exist.If
logging.properties
already exists, comment everything out. You may choose not to comment out other lines though, in case you want some logging.Append / insert the following to
logging.properties
:Create a file named
setenv.sh
in your$CATALINA_HOME/bin
folder if it doesn't already exist. (Where is$CATALINA_HOME
? Generally in/usr/share/tomcat...
but typeps -ef | grep tomcat
and hunt for the string
catalina.home
or something similar in the output to be sure.)Append / insert the following to
setenv.sh
:Restart Tomcat (e.g.
/etc/init.d/tomcat... restart
, depends on your OS)(Replace
tomcat...
with your actual version of Tomcat)除了在最新版本的 Solr 中此处编写的内容之外,您还可以选择配置慢速查询日志记录。您可以设置阈值,高于该阈值的查询将被视为长时间运行,并且此类查询将写入单独的日志中。
为此,请将
slowQueryThresholdMillis
添加到solrconfig.xml
文件中。例如,要将运行时间超过 2 秒的每个查询视为慢,您可以将以下内容添加到solrconfig.xml
中:In addition to what was written here in the recent versions of Solr, you have the option to configure slow query logging. You set the threshold above which a query will be considered long-running and such queries will be written in a separate log.
To do that add the
slowQueryThresholdMillis
to yoursolrconfig.xml
file. For example, to consider each query running above 2 seconds as slow you would put the following to thesolrconfig.xml
: