2

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?

4

1 回答 1

4

Log::Log4perl::Appender::File中有一个file_switch方法,在Description 部分简要介绍过。

如果要切换到不同的日志文件,请使用 file_switch($newfile) 方法,该方法将首先关闭旧文件句柄,然后打开指定新文件的句柄。

没有关于它的进一步文档,但我相信你可以使用它。

于 2017-09-07T12:16:59.773 回答