Solr 5.1:Solr正在创建太多日志文件 [英] Solr 5.1: Solr is creating way too many log files

查看:124
本文介绍了Solr 5.1:Solr正在创建太多日志文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理Solr 5.1创建太多日志文件的问题。每次Solr重新启动,并在整个星期内定期,Solr创建以下文件,我需要它停止:

I'm dealing with a problem where Solr 5.1 is creating way too many log files. Every time Solr is restarted, and periodically throughout the week, Solr creates the following files and I need it to stop:


  1. 该类型的文件solr_gc_xxxxxxxx_xxxx,其中x代表日期和某种识别号码。这些包含垃圾收集信息。

  2. solr_log_xxxxxxxx_xxxx类型的文件,其中x代表日期和某种识别号码。它们包含您在solr.log中找到的相同类型的信息。

  3. solr- [port] -console.log类型的一个文件。它总是只包含
    以下文本:警告:系统属性和/或JVM args
    设置。考虑使用--dry-run或--exec

  1. Files of the type solr_gc_xxxxxxxx_xxxx, where the x's stand for the date and some kind of identifying number, respectively. These contain garbage collection information.
  2. Files of the type solr_log_xxxxxxxx_xxxx, where the x's stand for the date and some kind of identifying number, respectively. These contain the same kind of information you'd find in solr.log.
  3. One file of the type solr-[port]-console.log. It always contains only the following text: WARNING: System properties and/or JVM args set. Consider using --dry-run or --exec

在一周内我累计了近30个类型1和2的文件!

In one week I racked up nearly thirty of files of the type 1 and 2!

更糟糕的是,文件类型1和2似乎不尊重我的 log4j.rootlogger 设置,而是填充INFO级别材料。

Even worse, file types 1 and 2 don't seem to respect my log4j.rootlogger setting and instead are filled with INFO level material.

以下是我的 log4j.properties file:

Here are the relevant parts of my log4j.properties file:

#  Logging level
solr.log=logs
log4j.rootLogger=WARN, file

#- size rotation with log cleanup.
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.MaxFileSize=100MB
log4j.appender.file.File=${solr.log}/solr.log
log4j.appender.file.MaxBackupIndex=0

我想做的是以下内容:


  1. 仅创建solr.log +一个备份文件。 solr.log应该定期覆盖。

  2. 不创建任何其他日志文件。

什么我可以做到这一点吗?

What can I do to accomplish this?

推荐答案

所以过了一段时间,我想出了如何解决这个问题。

So after some time, I figured out how to fix this.

回顾一下,Solr在启动时会持续创建一大堆带有solr_log *和gc_log *模式的文件,并且会在一天内定期创建。最终我遇到了一些相当严重的空间问题,因为Solr喜欢创造无数的日志。

To recap, Solr kept creating a whole bunch of files with the solr_log* and gc_log* patterns on startup and periodically throughout the day. Eventually I had some pretty serious space issues because of the endless amount of logs Solr likes to create.

导航到 / path / to / solr / bin 并找到 solr 脚本,该脚本在启动时运行。打开文件,查找以下内容,并注释掉 mv$ SOLR_LOGS_DIR / solr.log$ SOLR_LOGS_DIR / solr_log _ $(日期+%Y%m%d_%H%M)

Navigate to /path/to/solr/bin and locate the solr script, which runs at startup. Open the file, look for the following, and comment out mv "$SOLR_LOGS_DIR/solr.log" "$SOLR_LOGS_DIR/solr_log_$(date +"%Y%m%d_%H%M")":

# backup the log files before starting
if [ -f "$SOLR_LOGS_DIR/solr.log" ]; then
  if $verbose ; then
    echo "Backing up $SOLR_LOGS_DIR/solr.log"
  fi
  mv "$SOLR_LOGS_DIR/solr.log" "$SOLR_LOGS_DIR/solr_log_$(date +"%Y%m%d_%H%M")"
fi

如果您愿意,可以将其删除。您也可以尝试不使用 -f 标志,但在我的商店,我们喜欢它。

Or remove it, if you like. You could also try not using the -f flag but here at my shop we like it.

这将保留 solr.log ,但Solr不再进行任何备份。如果您想要每日备份,我建议在<$ c $中配置 TimeBasedRollingPolicy 或者更好的是 DailyRollingFileAppender c> log4j.properties 文件,可在 / path / to / solr / server / resources 下找到。

This will retain solr.log, but Solr won't make any more backups. If you want daily backups, I recommend configuring a TimeBasedRollingPolicy or, better yet, a DailyRollingFileAppender in the log4j.properties file, which can be found under /path/to/solr/server/resources.

如果需要,您还可以为Solr垃圾回收日志注释掉 mv 行,这将留下 solr_gc.log 仅限。

If you want, you can also comment out the mv line for the Solr garbage collection logs, which will leave you with solr_gc.log only.

如果像我一样,你有其他方法可以监控Solc的gc,那么你需要关闭gc完全记录。

If, like me, you have other ways you monitor gc for Solr, then you need to turn off gc logging completely.

在与 solr 脚本相同的目录中,打开 solr.in .sh (仅限Mac / Linux,我认为 solr.cmd 适用于Windows用户)并评论此行: #启用详细GC记录
GC_LOG_OPTS = - 详细:gc -XX:+ PrintHeapAtGC -XX:+ PrintGCDetails \
-XX:+ PrintGCDateStamps -XX:+ PrintGCTimeStamps -XX:+ PrintTenuringDistribution -XX: + PrintGCApplicationStoppedTime

In the same directory as the solr script, open solr.in.sh (Mac/Linux only, I think solr.cmd is for Windows users) and comment this line out: # Enable verbose GC logging GC_LOG_OPTS="-verbose:gc -XX:+PrintHeapAtGC -XX:+PrintGCDetails \ -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationStoppedTime".

您需要重新启动Solr。

You will need to restart Solr.

这篇关于Solr 5.1:Solr正在创建太多日志文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆