Skip to content
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

[Bug] Log::Log4perl::Appender::File::file_switch() ignores the create_at_logtime option #111

Open
XSven opened this issue Oct 27, 2021 · 2 comments

Comments

@XSven
Copy link

XSven commented Oct 27, 2021

Log-Log4perl-1.54

Switching the log file name using the file_switch() method, creates a new logfile even if the create_at_logtime option is set to true. Maybe the line 271 in Log::Log4perl::Appender::File should be changed from

$self->file_open();

to

$self->file_open() unless $self->{create_at_logtime};

@mohawk2
Copy link
Collaborator

mohawk2 commented Jun 1, 2022

Can you capture this in a bit of test code?

@XSven
Copy link
Author

XSven commented Apr 25, 2023

These 2 ok() test assertions should pass. Unfortunately the second one is failing.

#########################################################
# Testing create_at_logtime with file_switch()
#########################################################
unlink "${testfile}_6"; # delete leftovers from previous tests

$data = qq(
log4perl.category                  = DEBUG, Logfile
log4perl.appender.Logfile          = Log::Log4perl::Appender::File
log4perl.appender.Logfile.filename = ${testfile}_6
log4perl.appender.Logfile.create_at_logtime = 1
log4perl.appender.Logfile.layout   = Log::Log4perl::Layout::SimpleLayout
);

Log::Log4perl->init(\$data);
ok(! -f "${testfile}_6");

$app = Log::Log4perl->appenders()->{Logfile};
$app->file_switch("${testfile}_7");
ok(! -f "${testfile}_7");

unlink "${testfile}_6", "${testfile}_7";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants