SLF4J记录到文件与DB与Solr [英] SLF4J logging to file vs. DB vs. Solr

查看:161
本文介绍了SLF4J记录到文件与DB与Solr的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一些关于SLF4J日志记录的建议。

I need some suggestions in terms of SLF4J logging.

目前,我们正在使用SLF4J日志记录(log4j绑定)作为我们的Java Web应用程序,它使用简单的ConsoleAppender。我们的下一步是研究我们可以保存日志的地方。

Currently, we are using SLF4J logging (log4j binding) for a our Java web app, which uses the simple ConsoleAppender. Our next step is researching for places where we can save the logs.

我们的应用程序每天处理大约100,000封邮件。每条消息生成大约60-100行日志。我们的目标是能够快速搜索和查找失败的消息(使用messageId)并找出失败的原因。

Our app processes about 100,000 messages per day. Each message generates about 60 -100 lines of logs. Our goal is to be able to quickly search and find failed messages (using an messageId) and identify causes for the failure.

我的问题是:以下哪一项是存放日志的好地方:

My question is: which of the following is a good place to store our logs:


  • 文件

  • DB

  • Solr

谢谢。

推荐答案

考虑转离log4j并使用slf4j API的 logback 实现
Logback有一个广泛的 appenders 列表。

Consider switching away from log4j and using the logback implementation of the slf4j API Logback has an extensive list of appenders available.

我想也许你的问题更多的是关于使你的日志可搜索。答案取决于你要搜索的内容。

I think perhaps your questions is more concerning making your logs searchable. The answer depends on what you're search for.


  • 对于简单的应用程序,我只使用滚动文件appender并grep this for messages I感兴趣的是。

  • 更复杂的应用程序还会将消息记录到数据库。

  • 目前没有可用于log4j和logback的Solr appender。但是,使用 solrj API

  • 对于监视日志消息,有一个 lilith ,它是一个用于记录消息的远程GUI。
    不知道它的扩展程度如何,但它对于演示和简单监控来说无疑是有趣的。

  • For simple applications I just use a rolling file appender and grep this for the messages I'm interested in.
  • More complicated applications will additionally log messages to the database.
  • There is currently no Solr appender available for log4j and logback. It should however be easy to write using the solrj API
  • For monitoring log messages there is a lilith which is a remote GUI for log messages. Don't know how well it scales, but it's certainly interesting for demos and simple monitoring.

根据Sebastien的建议,还有一个 Graylog2 appender 用于logback。现在可在Maven Central中使用

As suggested by Sebastien there is also a Graylog2 appender for logback. Now available in Maven Central

<dependency>
    <groupId>me.moocar</groupId>
    <artifactId>logback-gelf</artifactId>
    <version>0.9.6p2</version>
</dependency>

当然这将取决于 graylog2 服务器。

Of course this will depend on having a graylog2 server installed.

这篇关于SLF4J记录到文件与DB与Solr的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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