Author image Robert Acock 🤞🌏
and 1 contributors


Log::Dispatch::XML - Collect one or more messages in XML format


 use Log::Dispatch::XML ();

 my $dispatcher = Log::Dispatch->new;
 my $channel = Log::Dispatch::XML->new(
  name      => 'foo',
  min_level => 'info',
 ) );
 $dispatcher->add( $channel );

 $dispatcher->warning( "This is a warning" );

 my $xml = $channel->xml;
 # <messages><warning><![CDATA[This is a warning]]></warning></messages>


The "Log::Dispatch::XML" module offers a buffering logging alternative for XML users. Messages are collected in the output channel until XML is created from them.


Apart from the methods provided by Log::Dispatch::Buffer (and implicitely from Log::Dispatch::Output), the following method is available:


 $xml = $channel->xml;

 $xml = $channel->xml( qq{log:messages xmlns:log=""} );

Return the XML of the messages collected on that channel. Two optional input parameters can be provided:

1 outer container

The name + attributes of the outer container that should be used to generate the XML. By default, "messages" will be assumed.

2 inhibit flush

By default, once XML is generated from the messages, the messages are flushed from the output channel. Specifying a true value causes the messages not to be flushed.


The XML format that is generated is very simple. The name and the attributes of the outer container is (implicitely) specified with the call to "xml". Inside this container, there is one container for each message: the name of that container is the same as the level of the message. The content of the container, is the text of the message. To ensure well-formedness of XML, the message is put inside a CDATA section.


 Log::Dispatch (1.16)
 Log::Dispatch::Buffer (any)


Elizabeth Mattijsen, <>.

maintained by LNATION, <>

Please report bugs to <>.


Copyright (c) 2004 Elizabeth Mattijsen <>. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.