Linux/c++ log rotation scheme -


I have a logger system that basically a thread std :: clog to write your data securely The way.

I also redirect std :: clog to a file like this:

  int main () {std :: ofstream logfile (Config :: logname, std :: ios :: app); Std :: streambuf * const old_buffer = std :: clog.rdbuf (logfile.rdbuf ()); // darshan of application std :: clog.rdbuf (old_buffer); }  

This works very well ... However, my application generates very large logs. I was wondering if my log file was properly rotated What would be a good way to do. Is there a safe way to exclude files through a cron function? I do not think so.

The only thing I can think is that it will definitely work if I have an application to open a new file, and it is banned when carrying logging mutes. But it seems like a cheap solution, and I'll need to see if it's time to turn the logs to take effect effectively. There may be a better way.

You can use the built-in log rotation method configured in /etc/logrotate.conf and / Or /etc/logrotate.d/ - This logrotate turns off sending a SIGUSR1 to your application as a signal and it is common to reopen all of your log files

<. / Html>

Comments