Your logfile output seems to indicate that what you really want is to split up a message that contains N newlines into N+1 separate messages (note the duplicate timestamps). That could be confusing, so I don't think Log4perl would want to support that.

If you just want to replace newlines by newline+indentation, as you've mentioned, you could use the appender in the FAQ.

To use this appender in conjunction with other appenders, you can define it as a 'composite' appender, Log::Log4perl::Appender::Buffer shows an example.

I could also envision a wrapper class around Log4perl that breaks up long messages before handing them over to Log4perl.

And on the layout level, maybe a custom cspec with some additional magic could do the trick.

Or, try to convince the guys on the log4perl-devel@ mailing list to add a layout element to the PatternLayout that does line breaking. Seems like a useful feature.


In reply to Re: Indenting, multi-line Log4perl Layout class? by saintmike
in thread Indenting, multi-line Log4perl Layout class? by splinky

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.