logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

Re: custom xml formats: msg#00003

Subject: Re: custom xml formats
On Wed, 2 Nov 2005, Antoine Solomon wrote:

> Well i am using my own custom layout to create logs for a program i have. I
> would like to instead create a custom XML file so that another application
> can read that file. Similar to the XML::Generator perl module. I am sort of
> a beginner at perl but would gladly like to help if anyone has a need for
> this.

Not sure what your custom format looks like but if you want something like

  <message>
      <date>2005/11/02 10:32:11</date>
      <text>A debug message!</text>
      <level>DEBUG</level>
      <category>main</category>
  </message>
  <message>
      <date>2005/11/02 10:32:11</date>
      <text>An info message!</text>
      <level>INFO</level>
      <category>main</category>
  </message>

then it can be accomplished like this:

use Log::Log4perl qw(:easy);
Log::Log4perl->easy_init({
    level  => $DEBUG,
    layout => <<'XML'});
  <message>
      <date>%d</date>
      <text>%m</text>
      <level>%p</level>
      <category>%c</category>
  </message>
XML

DEBUG "A debug message!";
INFO "An info message!";


-- Mike

Mike Schilli
m@xxxxxxxxxxxxxxx


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php


<Prev in Thread] Current Thread [Next in Thread>