Hi,

I'm trying to add values to the Log4perl configuration from my Catalyst config, 
via Perl hooks as per 
https://metacpan.org/module/Log::Log4perl#Perl-Hooks-in-the-Configuration-File 

My main Cat app file is:

        package MyApp::Cat;

        use strict;
        use warnings;
        use Catalyst::Runtime '5.70';
        use Log::Log4perl::Catalyst;

        __PACKAGE__->setup;

        sub my_test_hook {
                my $self = shift;
                return $self->config->{log4perl_conversion_pattern}; # E.g. 
'[%d] [MyApp::Cat] [%p] %m%n'.
        }
        
        __PACKAGE__->log( Log::Log4perl::Catalyst->new( 
__PACKAGE__->path_to(__PACKAGE__->config->{path_to_log4perl_conf})->stringify ) 
);

Then in my Log4perl config:

        log4perl.appender.LOGFILE.layout.ConversionPattern=\sub { return 
MyApp::Cat::my_test_hook(); }

Unfortunately, this only prints " \sub { return MyApp::Cat::my_test_hook(); } " 
in my log file!

Can anyone see how I may be able to fix this?

Regards,
Anthony

_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to