I am using Log::Log4perl as logger in my fastcgi based web application (in apache on WinXP). There is multiple processes with same code, so all pieces is writing to same log file. I wondered if it is a problem, so made simple test:
use Log::Log4perl qw(:easy); Log::Log4perl->init(\ qq{ log4perl.logger=DEBUG, A1 log4perl.appender.A1 = Log::Log4perl::Appender::File log4perl.appender.A1.filename = test2.log log4perl.appender.A1.syswrite = 1 log4perl.appender.A1.layout = SimpleLayout }); my $id = shift; for (1..20) { DEBUG "tick $_ from $id"; sleep(1); }
The script above (in file log_test.pl) is runned ten times with xargs like this
perl -E "say for 1..10" | xargs -n 1 -P 10 perl log_test.pl
Log file should contain 20 ticks from 10 processes
... DEBUG - tick 1 from 4 DEBUG - tick 1 from 5 DEBUG - tick 2 from 9 DEBUG - tick 2 from 10 ...
Unfortunately, there few entries missing. Typically it is like 5-10 entries out of 200 expected. I tried to enable/disable syswrite option, but it end up with similar results. I also tried to use Log::Log4perl::Appender::Synchronized, but it seems that IPC::SysV it is using does not work on Windows.
Any idea for better approach/solution?
-- thanks, Roman
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |