If a logger is cloned, it will hold a copy of the logging filehandle. When the clone is destroyed, Log::Dispatch::File should not close the filehandle, because the original logger object might still be alive. Instead of an explicit close, just rely on the garbage collector : it will automatically close the file when the last reference is destroyed.
Below is a simple demonstration of the problem :
use Log::Dispatch;
use Clone qw(clone);
my $obj = {log => Log::Dispatch->new(outputs => [
['Screen', min_level => 'debug', newline => 1 ],
['File', min_level => 'debug', newline => 1, filename => 'foobar.log'],
])};
my $clone = clone $obj;
$obj->{log}->info('cloned');
undef $clone;
$obj->{log}->info('after delete');
This produces an error "print() on closed filehandle"