-
Notifications
You must be signed in to change notification settings - Fork 158
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
RotatingFileHandler::_rotate doesn't handle rotation if file is opened in append mode #123
Comments
|
I am not sure how to reproduce this. I tried running the following : int main()
{
static char const* base_filename = "logfile.log";
quill::start();
quill::Handler* file_handler = quill::rotating_file_handler(base_filename, "w", 1024, 5);
quill::Logger* logger_bar = quill::create_logger("rotating", file_handler);
for (uint32_t i = 0; i < 20; ++i)
{
LOG_INFO(logger_bar, "Hello from {} {}", "rotating logger", i);
}
} Then i started my program again in append mode : int main()
{
static char const* base_filename = "logfile.log";
quill::start();
quill::Handler* file_handler = quill::rotating_file_handler(base_filename, "a", 1024, 5);
quill::Logger* logger_bar = quill::create_logger("rotating", file_handler);
for (uint32_t i = 20; i < 30; ++i)
{
LOG_INFO(logger_bar, "Hello from {} {}", "rotating logger", i);
}
} The above seems to be working and the log is appended. Can you maybe provide an example how to reproduce ? |
hi, Sorry for delayed response. I was using Windows (10, 11 or server). I tried your example code it works the first time but second run is giving the error. So it need those file to be there and that make the index to be corrupted. -antti |
Was checking the releases and noticed #157 maybe its related. |
thanks for reporting. I have fixed that in the new upcoming version v2 ac62be2 However, v2 does have limited support for wide chars on windows at the moment. If you are using wide chars then you will have to stick to v1.7.x. There is no fix for this in v1.7.x as it would take a bit more work to do that cross platform for c++14 without std::filesystem. |
closing for now since there is a fix in v2. Please re-open if any issues |
Thanks for fixing! We do actually use wide and char but this is not currently issue as we changed to use Fileappend when we noticed this. I have see more closely this wide char thing |
I am using RotatingFileHandler with append mode (a). This causes the rotation to stop working. Exceptions are:
quill::Handler *file_handler = quill::rotating_file_handler(logDirFile, "a", maxFileSize, backupCount);
Problem seems to be that the rotate() function doesn't initialize the
_currentIndex
variable when booting up.This causes rotation always trying to rename function to logfile.1.log which already exists and rename operation fails.
See the code from rotate function and the comment // then we will always rename the base filename to 1
If we open the file in 'w' mode the previous file gets overwritten and log writing is started ok.
Is this by design or can this be corrected?
The text was updated successfully, but these errors were encountered: