Open henry-spanka opened 9 years ago
Can't you just use logrotate?
We need some option from FastNetMon side for reopening log file.
But all other tasks should be implemented with logrotate :)
We have two approaches:
I prefer second option because log4cpp offer bundled thread safety:
3.2. Is log4cpp thread-safe? The same instance of the log4cpp::Category object (a logger) can be used from different threads simultaneously without explicit synchronization. Concurrent access to the appenders will be prevented by the logger object itself. It will lock internal mutex each time when it comes to writing into appenders. So, it is safe, for example, to write from the multiple threads to the same logger which appends to the same file. Although, log4cpp is configured in such a way that two different loggers append to the same appender (it may be a file), then there will be no way for the logging framework to arrange proper addition and things can get mixed up. So this way of configuration is not recommended.
And DailyRollingFileAppender do logrotation job perfectly: 1) We could automatically create new log file each day 2) We could remove older files (more than X total log files count)
Pavel, it is "normal" workaround - just restart fastnetmon after logrotate has done his job?
/var/log/fastnetmon/*.log
{
rotate 12
weekly
missingok
notifempty
compress
delaycompress
sharedscripts
postrotate
/usr/sbin/service fastnetmon restart > /dev/null
endscript
}
Hello!
Yes, that's fine. You can do it. Please check that you have netflow template cache enabled (sudo fcli show main netflow_templates_cache) to avoid traffic drops.
On Wed, Feb 6, 2019 at 11:24 AM kostyana notifications@github.com wrote:
Pavel, it is "normal" workaround - just restart fastnetmon after logrotate has done his job?
/var/log/fastnetmon/*.log { rotate 12 weekly missingok notifempty compress delaycompress sharedscripts postrotate /usr/sbin/service fastnetmon restart > /dev/null endscript }
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/pavel-odintsov/fastnetmon/issues/421#issuecomment-460989571, or mute the thread https://github.com/notifications/unsubscribe-auth/ACnfZin_Vz1NchVlf_v7SdbQytA_zM-pks5vKrtzgaJpZM4GDN35 .
-- Sincerely yours, Pavel Odintsov
Logrotate can also do a copy/truncate without changing the inode of the original file. No need to bounce the service.
/var/log/fastnetmon/*.log
{
rotate 6
daily
missingok
copytruncate
notifempty
delaycompress
}
Great! Thank you for sharing this advice!
We've added file for logrotate: https://github.com/pavel-odintsov/fastnetmon/blob/master/src/fastnetmon_logrotate
It wouldd be nice to rotate the fastnetmon log every day or so. My log file is now 55.000 lines big ;)