首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >旋转由nxlog创建的文件

旋转由nxlog创建的文件
EN

Stack Overflow用户
提问于 2015-10-07 18:16:53
回答 1查看 2.3K关注 0票数 1

我正在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中的重要部分

代码语言:javascript
复制
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。

任何帮助都是非常感谢的。谢谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-10-09 12:33:29

我认为问题在于om_file一直在向旋转文件中写入。您需要通知它,以便它将重新打开它的输出。下列措施应能发挥作用:

代码语言:javascript
复制
<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>
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32999592

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档