-
-
Notifications
You must be signed in to change notification settings - Fork 929
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Date-based log rotation? #210
Comments
Have a look at Log file rolling and see if helps |
Thanks Majid. That is not quite what I'm after: what I want to do is at a certain point of time is just change the filename of the log file that is being written to. The current size of the existing file does not matter. E.g. in a simple C-style logging system, where I have a global
I imagine there is something inside Easylogging++ that does what I need, but is any of it exposed in the public API? |
There is no internal timer that does it but you can certainly do what you are asking for using file rolling - this is theory so may want to test things Write your
If your application is multithreaded, ensure you test that it doesn't deadlock any locks |
Thanks Majid. I already have the timer, what I don't know how to do is tell the logger to close and re-open a file. Poking through the source, I think what I need is this function:
I don't actually want to do it for each level, though, just once per log file. However, I've only found functions that take The
or:
or even one file per month:
|
There is no such way but I am accepting this as suggestion since some libraries support it. |
In your timer, use This will reconfigure all the loggers with new file name and it will now write to new log file. |
I finally got to looking at this, and wrote a blog post (with a complete test program): I keep my filename in an external config file, so used a slightly different approach to your above suggestion. But it appears to be working nicely. :-) |
Does |
@abumusamq I see the roll-out.cpp. It's a single-thread program. What if multi-thread ? Does the callback need to be locked ? |
I've been using datestamp in the log filename:
FILENAME = "%datetime{%Y%M%d}.log"
For long-running processes this means it is still writing to 20140915.log a few days later. What is the recommended way to deal with this?
I can trigger a timer to run at midnight, but then I'm not sure what command to run to tell it to start a new log file, with a new filename.
The text was updated successfully, but these errors were encountered: