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]

Reply via email to