Newbie trying to rotate log files

Tags:

#1 mdemougin

Hello all,

I'm trying out NXLog to do some basic log file rotation. I'm just looking for it to rotate a specifed log file when it gets past 100K. For a PoC I've set up my nxlog.conf as follows, but no logs are ever rotated nor do any of the log_info calls ever get into the nxlog.log. Can someone help me with what I'm trying to accomplish? Thanks.

define TESTLOG 'C:\Logs\testlog.log' <Extension fileop> Module xm_fileop </Extension>

<Input logrotatein> Module im_file File "%TESTLOG%" </Input>

<Output logrotateout> Module om_file File %TESTLOG%

&lt;Schedule&gt;
    Every 30 seconds
	log_info('I am doing something');
    Exec if (file_size('%TESTLOG%') &gt;= 100K) 
	{
		log_info('I am rotating');
		file_cycle('%TESTLOG%',500);
		logrotate-&gt;reopen();
	}
&lt;/Schedule&gt;

</Output>

<Route 1> Path logrotatein => logrotateout </Route>

#2 b0ti Nxlog ✓ (Last updated )
#1 mdemougin
Hello all, I'm trying out NXLog to do some basic log file rotation. I'm just looking for it to rotate a specifed log file when it gets past 100K. For a PoC I've set up my nxlog.conf as follows, but no logs are ever rotated nor do any of the log_info calls ever get into the nxlog.log. Can someone help me with what I'm trying to accomplish? Thanks. define TESTLOG 'C:\Logs\testlog.log' <Extension fileop> Module xm_fileop </Extension> <Input logrotatein> Module im_file File "%TESTLOG%" </Input> <Output logrotateout> Module om_file File %TESTLOG% &lt;Schedule&gt; Every 30 seconds log_info('I am doing something'); Exec if (file_size('%TESTLOG%') &gt;= 100K) { log_info('I am rotating'); file_cycle('%TESTLOG%',500); logrotate-&gt;reopen(); } &lt;/Schedule&gt; </Output> <Route 1> Path logrotatein => logrotateout </Route>

The define configuration option is simply a string replacement operation.

define TESTLOG 'C:\Logs\testlog.log'
Exec if (file_size('%TESTLOG%') >= 100K)

The above yields this:

Exec if (file_size(''%TESTLOG%'') >= 100K)

Also logrotate->reopen(); references a module instance that does not exist. There are missing line terminators.

I don't think this would work at all without any configuration errors in nxlog.log...