in reply to Re^2: Gettign a logger with Log::Log4perl
in thread Gettign a logger with Log::Log4perl

The definition of $href is outside the sub run_tests(). Move it inside and you might get more ...
use Data::Dumper; sub run_tests { my $href = shift; # by doubt always try to dump the data # print STDERR Dumper( $href ); foreach my $test (keys %{$href}) { $log->info("running test $test with parameters $href->{$test}" +); } exit; }
Log by original code:
2016/10/31 13:47:06 7732 [0] logger_1175005.pl 23 ess2_loader - loggin +g successfully 2016/10/31 13:47:06 7732 [0] logger_1175005.pl 29 ess2_loader - trying + to spawn child for periodic check... 2016/10/31 13:47:06 7732 [11] logger_1175005.pl 31 ess2_loader - succe +ssfully spawned PID -5796 2016/10/31 13:47:06 -5796 [11] logger_1175005.pl 34 ess2_loader - runn +ing check as PID -5796
After var moved:
2016/10/31 13:47:21 19276 [0] logger_1175005.pl 23 ess2_loader - loggi +ng successfully 2016/10/31 13:47:21 19276 [0] logger_1175005.pl 29 ess2_loader - tryin +g to spawn child for periodic check... 2016/10/31 13:47:21 19276 [14] logger_1175005.pl 31 ess2_loader - succ +essfully spawned PID -5168 2016/10/31 13:47:21 -5168 [14] logger_1175005.pl 34 ess2_loader - runn +ing check as PID -5168 2016/10/31 13:47:21 -5168 [19] Tools.pm 22 Tools.run_test - running te +st baz with parameters foobar 2016/10/31 13:47:21 -5168 [19] Tools.pm 22 Tools.run_test - running te +st foo with parameters bar

Replies are listed 'Best First'.
Re^4: Gettign a logger with Log::Log4perl
by nikmit (Sexton) on Oct 31, 2016 at 16:04 UTC

    Thank you - that indeed worked but only comes to show I failed to provide an adequate example as the problem persisted in my application :)

    I made an effort to further/better isolate the problem and I think I have a solution. I was starting Dancer2 with a system($plackup $args) command. After looking at the source code of plackup, I started it directly in a fork:

    use Plack::Runner; if (my $ps = fork) { $log->info("successfully spawned PID $ps"); $SIG{CHLD} = "IGNORE"; } else { $log->info("starting Dancer2 as PID $$"); my @args = split(' ', $cmd); my $runner = Plack::Runner->new; $runner->parse_options(@args) or $log->logdie("Plack::Runner faile +d to parse startup options"); $runner->run or $log->logdie("failed to start Dancer2 app"); }

    I need to check whether failures to start are captured correctly, but on the logging front its a win, plus it should be a better way to start it anyway

    I still don't know why it was failing before - I did check that processes are running the same version of perl and @INC is the same when started via system() and directly