Re: Custom appender question about getRenderedMessage()
In your subclass on PatternLayout you can probably change the message by over-riding the format method. On 3/23/07, Bret Schuhmacher <[EMAIL PROTECTED]> wrote: Yes, thanks, that's what I've done. However, I cannot gain access to the fully rendered message, only the original message. I need access to the fully rendered message so I can do what I need to do. Rgds, Bret > -Original Message- > From: James Stauffer [mailto:[EMAIL PROTECTED] > Sent: Friday, March 23, 2007 10:57 AM > To: Log4J Users List > Subject: Re: Custom appender question about getRenderedMessage() > > 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? > > > %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: > > > > 2007-03-22 19:05:05,615 DEBUG > > > > [main][com.xx.TestMain:: ( 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.xx.TestMain:: ( 26)]-my message") so I can > > > > prepend "". > > > > > > > > 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 > > > > > > > > > > > > > > > > > >
RE: Custom appender question about getRenderedMessage()
Yes, thanks, that's what I've done. However, I cannot gain access to the fully rendered message, only the original message. I need access to the fully rendered message so I can do what I need to do. Rgds, Bret > -Original Message- > From: James Stauffer [mailto:[EMAIL PROTECTED] > Sent: Friday, March 23, 2007 10:57 AM > To: Log4J Users List > Subject: Re: Custom appender question about getRenderedMessage() > > 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? > > > %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: > > > > 2007-03-22 19:05:05,615 DEBUG > > > > [main][com.xx.TestMain:: ( 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.xx.TestMain:: ( 26)]-my message") so I can > > > > prepend "". > > > > > > > > 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
Re: Custom appender question about getRenderedMessage()
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? > %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: > > 2007-03-22 19:05:05,615 DEBUG > > [main][com.xx.TestMain:: ( 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.xx.TestMain:: ( 26)]-my message") so I can > > prepend "". > > > > 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 Staufferhttp://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 Staufferhttp://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]
RE: Custom appender question about getRenderedMessage()
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? > %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: > > 2007-03-22 19:05:05,615 DEBUG > > [main][com.xx.TestMain:: ( 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.xx.TestMain:: ( 26)]-my message") so I can > > prepend "". > > > > 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 Staufferhttp://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]
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? %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: 2007-03-22 19:05:05,615 DEBUG [main][com.xx.TestMain:: ( 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.xx.TestMain:: ( 26)]-my message") so I can prepend "". 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 Staufferhttp://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]
Custom appender question about getRenderedMessage()
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: 2007-03-22 19:05:05,615 DEBUG [main][com.xx.TestMain:: ( 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.xx.TestMain:: ( 26)]-my message") so I can prepend "". 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]