I would extend PatternLayout to change the message and only extend
RollingFileAppender to alter the rollOver functionality.

On 3/23/07, Bret Schuhmacher <[EMAIL PROTECTED]> wrote:
Thanks, James.  I did more digging around and was able to add a "%s" to
my ConversionPattern using a custom PatternLayout subclass.  I can get
my custom text to print out where I want now.

BUT - the custom text is based on the rest of the row - there is some
amount of calculation that must be done based on the contents of the
rest of the row.  I need to get the *fully rendered message* as it would
be written to the file so I can do the calculations and create the
custom text that goes on the front.  In addition, I need to alter the
rollOver functionality, so I think subclassing the RollingFileAppender
is needed.

Unfortunately, getRenderedMessage just returns the original text of the
message to be logged, not the message that has all the modifiers
replaced (i.e. with time, thread, class, etc.).  Is it possible to get
the fully rendered message?

Thanks,

Bret


> -----Original Message-----
> From: James Stauffer [mailto:[EMAIL PROTECTED]
> Sent: Friday, March 23, 2007 10:03 AM
> To: Log4J Users List
> Subject: Re: Custom appender question about getRenderedMessage()
>
> If you want to change the text of the message, you shouldn't do that
in
> the appender -- the layout is a much better place to do that.
>
> Can you just change your ConversionPattern to the following and not
> subclass RollingFileAppender?
> <my custom text> %d %5p [%t][%40C::%-20M(%3L)]-%m%n
>
> On 3/22/07, Bret Schuhmacher <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > I'm trying to extend RollingFileAppender.  I want to manipulate the
> > *complete* message that's logged by prepending something to the
> > message just before it's dumped into the file.
> >
> > My custom class's append() tries to create a new LoggingEvent from
> the
> > given LoggingEvent, prepending my text to the
> > event.getRenderedMessage(), then calls
> super.append(myNewLoggingEvent).
> > Unfortunately,  getRenderedMessage just returns the original message
> I
> > wanted logged, not the full message rendered with my
> ConversionPattern.
> > My ConversionPattern is set to this, btw:
> > %d %5p [%t][%40C::%-20M(%3L)]-%m%n
> >
> > Said another way, I want this:
> > logger.debug("my message");
> >
> > to get rendered and written to file like this:
> > <my custom text> 2007-03-22 19:05:05,615 DEBUG
> > [main][com.xxxxxx.TestMain::<init> ( 26)]-my message
> >
> > Is there a way to make this happen?  I can't seem to get my hands on
> > the full, rendered message ("2007-03-22 19:05:05,615 DEBUG
> > [main][com.xxxxxx.TestMain::<init> ( 26)]-my message") so I can
> > prepend "<my custom text>".
> >
> > I've tried creating an ObjectRenderer, too, but I don't think that's
> > the way I should go (is it?).  If I could grab the full rendered
> > message and prepend my String and then *reset* the rendered message
I
> > think I'd be fine, but I'm not sure...
> >
> > FWIW, I'm using 1.2.14.
> >
> >
> > Thanks!
> >
> > Bret
> >
> >
> >
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
> --
> James Stauffer        http://www.geocities.com/stauffer_james/
> Are you good? Take the test at http://www.livingwaters.com/good/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--
James Stauffer        http://www.geocities.com/stauffer_james/
Are you good? Take the test at http://www.livingwaters.com/good/

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to