问题描述
我们在Linux上有一个使用 syslog 机制的应用程序.在花了一周的时间试图弄清楚为什么该应用程序运行速度比预期的慢后,我们发现,如果消除syslog并直接写入日志文件,性能将大大提高.
We have an application on Linux that used the syslog mechanism. After a week spent trying to figure out why this application was running slower than expected, we discovered that if we eliminated syslog, and just wrote directly to a log file, performance improved dramatically.
我了解为什么syslog比直接写文件要慢.但是我想知道:是否可以通过配置syslog来优化其性能?
I understand why syslog is slower than direct file writes. But I was wondering: Are there ways to configure syslog to optimize its performance?
推荐答案
您可以配置syslogd(至少rsyslog)在日志消息后不同步日志文件,方法是在日志消息路径前添加-"配置文件.这样可以提高性能,但要避免在崩溃中丢失日志消息.
You can configure syslogd (and rsyslog at least) not to sync the log files after a log message by prepending a "-" to the log file path in the configuration file. This speeds up performance at the expense of the danger that log messages could be lost in a crash.
这篇关于可以提高syslog的性能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!