Cycling multiple files
Hello, I'm logging event logs from a custom c++ app to a server and am trying to setup file cycling for both the application event logs and NXLog log file. When I add a second Output to my Route, I start to see the event logs showing up in the NXLog log file, which I wasn't expecting. I'm not sure how to approach this ... should I be setting up a second path for the NXLog cycling? Here's what my config file is looking like:
Keep 2 weeks of app log files
<Output app_log_cycle> Module om_file File 'C:/Users/Jeremy/Documents/myApp/myApp.log' <Schedule> When @daily <Exec> file_cycle(file_name(), 7); app_log_cycle->reopen(); </Exec> </Schedule> </Output>
Keep 2 weeks of nxlog log files
<Output nxlog_log_cycle> Module om_file File 'C:/Program Files (x86)/nxlog/data/nxlog.log' <Schedule> When @daily <Exec> file_cycle(file_name(), 14); nxlog_log_cycle->reopen(); </Exec> </Schedule> </Output> <Route 1> Path watchfile => syslogout, app_log_cycle, nxlog_log_cycle </Route> Thanks++ for any tips! Jeremy
Hello Jeremy,
Event logs showing in your nxlog.log
file is something one should expect taking into account your conf
file. In the route:
<Route 1>
Path watchfile => syslogout, app_log_cycle, nxlog_log_cycle
</Route>
you explicitly push events to this file.
If you want just rotate it, you might try doing something like this:
<Extension fileop>
Module xm_fileop
# Check the log file size every hour and rotate if larger than 1 MB
<Schedule>
Every 1 hour
Exec if (file_size('%LOGFILE%') >= 1M) file_cycle('%LOGFILE%', 2);
</Schedule>
# Rotate log file every week on Sunday at midnight
<Schedule>
When @weekly
Exec file_cycle('%LOGFILE%', 2);
</Schedule>
</Extension>
This example is taken right out of our reference manual..
Best regards,
Rafal