change rotate file name with file_cycle
Hello :),
I make a file rotation when my logs size exceed with 'file_cycle'.
I have something like this :
Exec if outUDP->file_size() > 10k \
{ \
log_info('size exceeded'); \
file_cycle(%LOGDIR% + $programSource + '\\' + get_var('date') + '.log'); \
outUDP->reopen(); \
}
So my logs paths are :
C:\logs\programA\20170329.log
C:\logs\programA\20170329.log.1
C:\logs\programA\20170329.log.2
C:\logs\programB\20170329.log.1
C:\logs\programB\20170329.log.2
But I wanted something more like :
C:\logs\programA\20170329.log
C:\logs\programA\20170329.1.log
C:\logs\programA\20170329.2.log
C:\logs\programB\20170329.1.log
C:\logs\programB\20170329.2.log
I wanted to make it by myself using 'rotate_to' instead of 'file_cycle' .
The probleme is if nxlog restarts, I need it to continue the file rotation without overwrite the files that already exist. I can't check if C:\logs\programA\20170329.1.log exists then C:\logs\programA\20170329.2.log until I find the last...
It is possible to change it using 'file_cycle'? Or do you have another idea?
Thanks :)
Why don't you just write to a file with the timestamp in the filename directly?
<Output out> Module om_file File
%LOGDIR% + $programSource +"_" + strftime(now(), "%Y%m%d%H%M%S");