您是否认为使用MongoDB JSON数据库从应用程序存储日志文件是一个好主意,为什么?

对我来说,唯一的优点是架构抽象,但我认为这也是一个弱点,我们无法确保日志文件的完整性。

有帮助吗?

解决方案

显然我有偏见(我在MongoDB上工作),但我认为它对日志非常有效。

原因:

  • 插入和更新是快速的...您可以每秒做数千个
  • 除了普通查询外,您还可以使用JavaScript运行分析并生成报告。您可以在每晚运行的cron工作,这对您的日志进行了很好的地图。
  • 您可以使用限制收藏的收藏品,这些收藏品的作用像排队一样,仅保留最新的nkbs/mbs/gbs的日志

我不确定您的意思是“确保日志文件的完整性” ...您的意思是您担心不知道您要抽出的文档的字段吗?如果是这样,我认为您会发现在关系数据库中处理空字段并更加灵活并不困难。

也可以看看: MongoDB博客文章有关记录.

其他提示

I'm using MongoDB to store logs from many applications and it's working out very well so far.

You might want to take a look at the slides from a presentation on Logging Application Behavior to MongoDB that I gave at Mongo SV and at the last MongoDB SF Meetup for more background on why I think it is good for logging, as well as for info on libraries for Java, Python, Ruby, PHP and C# that support logging to MongoDB.

I'm now the main committer on log4mongo-java, Log4J appenders for MongoDB. So, it's probably not too surprising that that's what I'm using.

With respect to log integrity, I assume you mean confidence that it hasn't been modified after it was written. One option you have, at least with log4mongo-java, it to store logging events in a database that requires authentication. That would limit to some degree the number of users who could add, delete or update events.

In addition, you could set up a replication slave that is tightly locked down. Frequent backups of the slave would at least limit the time during which the set of logged events could be modified.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top