I am the author of the
Log4perl::KISS
module, and I want to convert the log_open
function so that it can switch the current log file on the fly at any time without full Log::Log4perl
reinitialization.
I know that the file appender in Log4perl
can switch to the file with the same name (this possibility was added to allow log rotation), but I need to switch to a different filename. I don't know how to change the filename used by the file appender before switching to another file handle.
How to change the appender's filename if it is possible?
There is a file_switch
method in Log::Log4perl::Appender::File that's briefly touched upon in the Description section.
If you want to switch over to a different logfile, use the file_switch($newfile) method which will first close the old file handle and then open a one to the new file specified.
There's no further documentation on it, but I believe you can use that.