Append to TAP output
use Test2::V0;
use Log::Log4perl qw( :easy );
Log::Log4perl::init(\<<CONF);
log4perl.rootLogger=ERROR, TAP
log4perl.appender.TAP=Log::Log4perl::Appender::TAP
log4perl.appender.TAP.method=diag
log4perl.appender.TAP.layout=PatternLayout
log4perl.appender.TAP.layout.ConversionPattern="[%rms] %m"
CONF
DEBUG "this message doesn't see the light of day";
ERROR "This gets logged to TAP using diag";
ok 1;
done_testing;outputs:
# Seeded srand with seed '20250911' from local date.
# "[0ms] This gets logged to TAP using diag"
ok 1
1..1
This very simple Log::Log4perl appender sends log output via Test2::API to TAP
(or any other format supported by Test2::API). It also works with
Test::Builder and Test::More so long as you have Test2::API
installed. It only takes one special argument, the method, which can
be either diag or note.
-
Main module documentation for
Log4perl. -
Similar module but for Log::Dispatch instead of
Log4perl.
Graham Ollis [email protected]
This software is copyright (c) 2017-2025 by Graham Ollis.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.