I am using nxlog-ce on Windows Server 2012 R2.
nxlog is outputting two txt files.
I would like to rotate these two files every hour. I want the active log to maintain the same name, logfileA.txt logfileB.txt and new rotated files to be created logfileA.txt.2 logfileB.txt.2
I only ever want there to be two files for each log logfileA.txt and logfileA.txt.2 but never a logfileA.txt.3
Here are the important parts from my current 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>
In this configuration, when the nxlog service starts it immediately creates logfileA.txt.1 and logfileB.txt.1 However, the system never rotates the logs. logfileA.txt.2 and logfileB.txt.2 are never created.
I am having trouble finding resources covering how to setup log rotation with nxlog.
Any help is greatly appreciated. Thank you!
I think the issue is that om_file keeps writing into the rotated file. You need to notify it so that it will reopen its output. The following should work:
<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>