Perl: Will Log :: Log4perl work in a multi-threaded environment?

I am using logging vai Log :: Log4perl in my perl script; I am wondering if making multiple calls to write to the same log object will cause incorrect / erroneous behavior.

I use Appender :: File to write the log as follows:

$log->info("Launching commands...");
foreach my $param (@params) {
    push @thread_handles, async {
        system("$param");
        $log->info("$param COMPLETE");
        logstatus($?);
    };
}

$_->join() foreach @thread_handles;
$log->info("Commands completed...");
+2
source share
3 answers

Log :: Log4perl with the file file will work by default , but some overlaps can occur in multi-threaded or multi-processor using the same log file.

Log:: Log4perl:: Appender:: Synchronized . . Log:: Log4perl mod_perl? FAQ .

+2

Synchronized appender . : ? perlthrtut, . . - ?

threads::shared , threads::shared documentation , , . perl 5.8.8, , , .

, . log4perl , . , .

: , . log4perl, script, - , , . . , , , . .

+1

Log4perl , .

, , .

, pid logmessage.

, .

I select one log file with pid or some kind of stream id. I use this kind of logging without problems.

Yours faithfully,

0
source

Source: https://habr.com/ru/post/1537930/


All Articles