我正在Windows 2012 R2上使用nxlog-ce。
nxlog输出两个txt文件。
我想每小时轮换这两个文件。我希望活动日志维护相同的名称、logfileA.txt logfileB.txt和要创建的新的旋转文件logfileA.txt.2 logfileB.txt.2。
我只希望每个日志logfileA.txt和logfileA.txt.2都有两个文件,但不希望有一个logfileA.txt.3。
以下是我当前nxlog.config中的重要部分
define LOGFILE_Atxt C:\test\logfileA.txt
define LOGFILE_Btxt C:\test\logfileB.txt
<Extension fileop>
Module xm_fileop
<Schedule>
Every 1 hour
Exec file_cycle('%LOGFILE_Atxt%', 2);
Exec file_cycle('%LOGFILE_Btxt%', 2);
</Schedule>
</Extension>
<Output loga_out>
Module om_file
file 'c:\test\logfileA.txt'
CreateDir TRUE
</Output>
<Output logb_out>
Module om_file
file 'c:\test\logfileB.txt'
CreateDir TRUE
</Output>
<Route loga_route>
Path loga_input => loga_out
</Route>
<Route logb_route>
Path logb_input => logb_out
</Route>但是,在此配置中,当nxlog服务启动时,它会立即创建logfileA.txt.1和logfileB.txt.1,但是,系统不会旋转日志。不创建logfileA.txt.2和logfileB.txt.2。
我有困难找到资源,包括如何设置日志旋转与nxlog。
任何帮助都是非常感谢的。谢谢!
发布于 2015-10-09 12:33:29
我认为问题在于om_file一直在向旋转文件中写入。您需要通知它,以便它将重新打开它的输出。下列措施应能发挥作用:
<Extension fileop>
Module xm_fileop
</Extension>
<Output loga_out>
Module om_file
file 'c:\test\logfileA.txt'
CreateDir TRUE
<Schedule>
Every 1 hour
Exec file_cycle('%LOGFILE_Atxt%', 2);
Exec loga_out->reopen();
</Schedule>
</Output>
<Output logb_out>
Module om_file
file 'c:\test\logfileB.txt'
CreateDir TRUE
<Schedule>
Every 1 hour
Exec file_cycle('%LOGFILE_Btxt%', 2);
Exec logb_out->reopen();
</Schedule>
</Output>https://stackoverflow.com/questions/32999592
复制相似问题