Thanks Ceki!<br><br>I was happily hacking along when it suddenly struck me - &#39;foo&#39; is not a string, but a complex object which is converted to a printable string by a Converter. So, sticking to that logback design it&#39;s impossible to tell the final length of foo&#39;s string value in the TurboFilter or in writeLoopOnConverters(). Bummer!<br>
<br>/Anders<br><br><div class="gmail_quote">On Tue, Sep 22, 2009 at 13:59, Ceki Gulcu <span dir="ltr">&lt;<a href="mailto:ceki@qos.ch">ceki@qos.ch</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
Since you system is based on logback-core and not logback-classic, you could create a turbo filter which instead of returning ACCEPT, DENY, NEUTRAL could return an array of MyEvent instances which would correspond closely to what you have in mind.<br>

<br>
<br>
Anders Hammar wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im">
Thanks Ceki! I knew I could count on you replying quickly.<br>
<br>
The framework here is the auditing framework I constructed some 1,5 years ago for a customer. They&#39;ve now realized this requirement.<br>
<br>
I was kind of hoping that I could add some step before the layout gets the event. In that step, I could check the event, and if necessary split it into x events. And then the layout would get these n events instead and do the normal logging on each of them.<br>

I had a look at the filters, but they only handle allow/block kind of things. This would be some other kind of &quot;filter&quot;. Maybe there&#39;s no advantage going down this path compared to your suggestion...<br>
<br>
/Anders<br>
<br></div><div><div></div><div class="h5">
On Tue, Sep 22, 2009 at 11:38, Ceki Gulcu &lt;<a href="mailto:ceki@qos.ch" target="_blank">ceki@qos.ch</a> &lt;mailto:<a href="mailto:ceki@qos.ch" target="_blank">ceki@qos.ch</a>&gt;&gt; wrote:<br>
<br>
<br>
    Hello Anders,<br>
<br>
    Logback-core? Nice.<br>
<br>
    If only the field &#39;foo&#39; needs to be split, then just override the<br>
    converter for the field foo to do the splitting, and you are done.<br>
    However, you requirements differ as you also require the repetition<br>
    of other fields.<br>
<br>
    The approach which seems the most logical to me, would be to derive<br>
    a sub-class from PatternLayoutBase overriding the<br>
    writeLoopOnConverters method so that when the foo field needs<br>
    splitting, you would loop over the converter chain as many times as<br>
    necessary.<br>
<br>
    Here is a possible implementation:<br>
<br>
    class MyPatternLayout extends PatternLayoutBase&lt;MyEvent&gt; {<br>
<br>
     ...<br>
<br>
     protected String writeLoopOnConverters(MyEvent event) {<br>
       Foo foo = event.getFoo();<br>
       StringBuilder sb = new StringBuilder();           String[] fooParts = split(foo);<br>
       for(String s: fooParts) {<br>
         // construct a new event from &#39;event&#39; so that foo has only one part<br>
         MyEvent splitEvent = new MyEvent(event, s);<br>
         String line = super.writeLoopOnConverters(splitEvent);<br>
         sb.append(line);<br>
         sb.append(CoreConstants.LINE_SEPARATOR);<br>
       }<br>
       return sb.toString();<br>
     }<br>
    }<br>
<br>
    HTH,<br>
<br>
<br>
    Anders Hammar wrote:<br>
<br>
        Hi,<br>
<br>
        I have a framework that utilizes logback-core for logging. Due<br>
        to limitations in the software reading the log files, a new<br>
        requirement is that long data should be split on multiple rows.<br>
        I&#39;m trying to figure out if there a simple way of doing this?<br>
<br>
        More info: What I have is an extension of the PatternLayoutBase<br>
        which adds the converters for my event class. I&#39;m using the<br>
        standard RollingFileAppender. So, let&#39;s say I have a<br>
        FooConverter, which gets the foo info from the event. But, when<br>
        logging to the file, the foo info part must never be longer than<br>
        x chars. If it is, it should be split on multiple rows. Other<br>
        data (generated by other converters) should then be repeated.<br>
<br>
        Any suggestions on how to do this in a clean logback way is<br>
        appreciated! What I&#39;m currently thinking is to loop on the<br>
        converters (calling PatternLayoutBase.writeLoopOnConverters<br>
        multiple times), but I need to know when that&#39;s required...<br>
        Anyone done something similar?<br>
<br>
        /Anders<br>
<br>
<br>
    --     Ceki Gülcü<br>
    Logback: The reliable, generic, fast and flexible logging framework<br>
    for Java.<br>
    <a href="http://logback.qos.ch" target="_blank">http://logback.qos.ch</a><br>
    _______________________________________________<br>
    Logback-user mailing list<br></div></div>
    <a href="mailto:Logback-user@qos.ch" target="_blank">Logback-user@qos.ch</a> &lt;mailto:<a href="mailto:Logback-user@qos.ch" target="_blank">Logback-user@qos.ch</a>&gt;<div class="im"><br>
    <a href="http://qos.ch/mailman/listinfo/logback-user" target="_blank">http://qos.ch/mailman/listinfo/logback-user</a><br>
<br>
<br>
<br></div>
------------------------------------------------------------------------<div class="im"><br>
<br>
_______________________________________________<br>
Logback-user mailing list<br>
<a href="mailto:Logback-user@qos.ch" target="_blank">Logback-user@qos.ch</a><br>
<a href="http://qos.ch/mailman/listinfo/logback-user" target="_blank">http://qos.ch/mailman/listinfo/logback-user</a><br>
</div></blockquote><div><div></div><div class="h5">
<br>
-- <br>
Ceki Gülcü<br>
Logback: The reliable, generic, fast and flexible logging framework for Java.<br>
<a href="http://logback.qos.ch" target="_blank">http://logback.qos.ch</a><br>
_______________________________________________<br>
Logback-user mailing list<br>
<a href="mailto:Logback-user@qos.ch" target="_blank">Logback-user@qos.ch</a><br>
<a href="http://qos.ch/mailman/listinfo/logback-user" target="_blank">http://qos.ch/mailman/listinfo/logback-user</a><br>
</div></div></blockquote></div><br>