2016-11-10 235 views
4

每当newsyslog轮转日志文件后,syslog都会停止登录到文件。直到syslogd重启完成。系统日志在日志轮转后停止日志记录

(myserver:wheel)# logger -p local1.info -t myprocess "hello thiru"; ll myfile.log; cat myfile.log 
-rw-r--r-- 1 root wheel  0B Nov 10 11:26 myfile.log 

(myserver:wheel)# /etc/rc.d/syslogd restart 
Stopping syslogd. 
Starting syslogd. 

(myserver:wheel)# logger -p local1.info -t myprocess "hello thiru"; ll myfile.log; cat myfile.log 
-rw-r--r-- 1 root wheel 44B Nov 10 12:04 myfile.log 
Nov 10 12:04:31 myserver myprocess: hello thiru 
(myserver:wheel)# 

Linux(使用logrotate),我们可以通过在logroate的conf的postrotate部分做syslog/rsyslog restart解决这个问题。

newsyslog有没有类似postrotate的东西?

编辑:

系统日志和newsyslog conf文件:

(TPC-E11-36:wheel)# cat /etc/newsyslog.d/newsyslog-myprocess.conf 
/var/log/myfile.log 644 20 10000 * Z 

(TPC-E11-36:wheel)# cat /etc/syslog.d/syslog-myprocess.conf 
!myprocess 
local1.info /var/log/myfile.log 
(TPC-E11-36:wheel)# 
+2

见'人newsyslog.conf',但默认情况下'syslogd'接收时,日志文件,除非任何一个'N'标志或**另一个进程旋转的信号**已被指定。检查你的'newsyslog.conf'或'newsyslog.conf.d/*'文件。 –

+0

@RichardSmith我不知道如何在'newsyslog.conf'中指定一个进程?而且我还没有使用'N'标志。 –

+1

我无法复制该问题。如果我将行添加到我的'/ etc/syslog.conf'文件中并调用'newsyslog -f newsyslog-cnd.conf',日志文件将被轮换,并创建一个新的日志文件, 'logger'正常工作到新文件中。我不认识你的子目录'newsyslog.d'和'syslog.d',并且在日志轮转后我没有得到'0B'文件。 –

回答