gpt4 book ai didi

windows - 轮转由 nxlog 创建的文件

转载 作者:可可西里 更新时间:2023-11-01 11:26:58 24 4
gpt4 key购买 nike

我在 Windows Server 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 设置日志轮换的资源。

非常感谢任何帮助。谢谢!

最佳答案

我认为问题在于 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>

关于windows - 轮转由 nxlog 创建的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32999592/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com