Community discussions

MikroTik App
 
StudentMik90
just joined
Topic Author
Posts: 10
Joined: Wed Jan 16, 2019 5:19 pm

Firewall logs to files - naming convention

Thu Mar 09, 2023 9:47 am

Hi,

I am testing firewall logging options with saving to file (USB stick) for future offline processing from files.
I noticed that if I there are multiple logs files created, the newest file log name is always in log ending with 0.txt and older files are renamed by numbers in order.. previously 0.txt file is renamed to1.txt after new log file is created, etc..

Is there way how to keep names of logs without change upon next file creation? if log file is initially created with xxx.0.txt it will remain 0.txt and new files will use name e.g. xxx.1.txt, xxx.2.txt?

Thanks.
 
User avatar
mkx
Forum Guru
Forum Guru
Posts: 11433
Joined: Thu Mar 03, 2016 10:23 pm

Re: Firewall logs to files - naming convention

Thu Mar 09, 2023 10:23 am

This kind of naming is very common in linux when "logrotate" facility is used (the differentce is that in linux normally the file being actively written to has name without "index" (e.g. 0) in it). Plus it's pretty easy to trim excess files and keep the "index" in file name coherent.

So I'd highly appreciate if current naming convention is kept in future.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Firewall logs to files - naming convention

Thu Mar 09, 2023 11:11 am

Is there way how to keep names of logs without change upon next file creation?
Set file count to 1 and lines per file 2000...
1 + 1 = 1...
 
pe1chl
Forum Guru
Forum Guru
Posts: 10195
Joined: Mon Jun 08, 2015 12:09 pm

Re: Firewall logs to files - naming convention

Thu Mar 09, 2023 11:49 am

This kind of naming is very common in linux when "logrotate" facility is used (the differentce is that in linux normally the file being actively written to has name without "index" (e.g. 0) in it). Plus it's pretty easy to trim excess files and keep the "index" in file name coherent.

So I'd highly appreciate if current naming convention is kept in future.
Well, I hate that convention. I always change the logrotate config so it renames files to an index specifying the date.
# use date as a suffix of the rotated file
dateext
The reason is that I do not like to see the same file being renamed to different names later on. I use rsync backups to a filesystem with snapshots, so that is a waste of space.
Also, in a router the files are not really safe so I download the logs regularly to my computer. It is a nuisance that the same log.0.txt is a different file all the time and I have to carefully watch if it has already been rotated on the router to prevent overwriting an older log in the download directory. So I sure would appreciate a "dateext" checkmark in the log file config.
 
User avatar
mkx
Forum Guru
Forum Guru
Posts: 11433
Joined: Thu Mar 03, 2016 10:23 pm

Re: Firewall logs to files - naming convention

Thu Mar 09, 2023 12:03 pm

I agree that dateext is very useful option (if it's handled properly by logrotate implementation). I just strongly disagree to deviate in ROS from the way index numbering works in general linux.

Who is online

Users browsing this forum: 4l4R1, bizarrity, esj, Guntis, h1ghrise, robertkjonesjr, Yahoo [Bot] and 86 guests