English 中文(简体)
通过电线记录日志?
原标题:
  • 时间:2008-11-27 18:05:03
  •  标签:

我们有一些情况,在这些情况下,我们会将许多日志文件写入主机,从而增加主机的输入/输出。是否有任何好的开源日志记录解决方案?

应用程序语言是C++,在Red Hat Linux 3上。

问题回答

一个非常简单的日志选项是使用syslog,并依赖于(正确配置后)syslog守护程序将其转发到远程服务器。

看一看:

打开日志()

syslog()

关闭日志()

And: 而且

syslog.conf日志配置文件

有记录库可以帮助你,取决于你的应用程序语言。但如果I / O是一个问题,那么网络带宽可能是一个更大的问题。

第一组问题:

  • Do you need all those log files?
  • All the time?
  • Can you control how much logging occurs?
  • Why not?

第二组问题:

  • Why are your log writing operations slow?
  • Are you using inappropriate operations (for example, O_SYNC or related options on POSIX)?
  • How many disk drives do you have?
  • Can you gain by having different log files on different drives (or, at least, having the log files on a different drive from where the other files are stored)?

正如@igalse所说,有一些记录库可用。对于C ++,您应该查看Boost中提供的内容,但也有无疑有其他来源。

对于C ++,Boost尚不包含日志记录库。 但是您可以使用由John Torjo编写的最先进的候选库,此处

它允许过滤一些日志记录(如果日志记录非常重要,以至于它成为性能问题,那么您可能需要该功能),并设置不同的目标,例如流。

如果主机上的I/O不必要地受到影响,那么我认为你要么是:

  • Doing FAR too much logging - logging sufficiently that it approaches IO write speed on a sustained basis is probably too much - as even the most modest hardware can comfortably do several megabytes per second without a problem
  • Doing too many flushes of your logs - this is more likely. Syslogd flushes the log quite a lot by default (too much for log-intensive applications) - this is so that log files are durable in the event of a crash - but generates a lot of IOs. Syslogd can be reconfigured on a per-file basis (see its man page) not to flush the files out so often.

如果网络服务器存在相同问题,登录不会解决这些问题-事实上,如果有多个主机登录到同一服务器,则会使它们变得更糟。

应用语言是在Red Hat Linux 3上的C++。





相关问题
热门标签