You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by selezovikj <se...@gmail.com> on 2008/10/29 14:29:33 UTC

No setMessage in LoggingEvent

Dear All, 

I was wondering why doesn't LoggingEvent have the setMessage method, but
only getMessage() ? 
I have a LoggingEvent passed to a queue, and then I get the message of the
LoggingEvent using getMessage(), do some filtering on it, and later I want
to put the filtered message back in the LoggingEvent, so that later I can
pass the whole LoggingEvent and log it using callAppenders(event) (so that I
can keep the original timestamp, level etc. ) ? ? ? 
-- 
View this message in context: http://www.nabble.com/No-setMessage-in-LoggingEvent-tp20227123p20227123.html
Sent from the Log4j - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: No setMessage in LoggingEvent

Posted by selezovikj <se...@gmail.com>.
Since there is no setMessage in the LogginEvent class, I guess I should
create a new LoggingEvent. 
Let us say event is the event from which I extract the message with
getMessage() method: 
String actualMessage = (String) event.getMessage();

actualMessage = process(something);

Later I would like to call something like event.setMessage(actualMessage),
and then pass the event to further processing. 

However, there is not setMessage method defined. 
I guess the best thing to do is create a new LoggingEvent, which will retain
the level, timestamp etc. of the "event" LoggingEvent: 

LoggingEvent filteredEvent = new LoggingEvent(event.getFQNOfLoggerClass(), 
				event.getLogger(), 
				event.getTimeStamp(), 
				event.getLevel(), 
				actualMessage ,
				new Exception());

This however gives an error: 

java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)

CAUSED BY: Caused by: java.lang.NoSuchMethodError:
org.apache.log4j.spi.LoggingEvent.getLogger()Lorg/apache/log4j/Category;


How come there is no method getLogger() ? 

ANy advice ?




selezovikj wrote:
> 
> Dear All, 
> 
> I was wondering why doesn't LoggingEvent have the setMessage method, but
> only getMessage() ? 
> I have a LoggingEvent passed to a queue, and then I get the message of the
> LoggingEvent using getMessage(), do some filtering on it, and later I want
> to put the filtered message back in the LoggingEvent, so that later I can
> pass the whole LoggingEvent and log it using callAppenders(event) (so that
> I can keep the original timestamp, level etc. ) ? ? ? 
> 

-- 
View this message in context: http://www.nabble.com/No-setMessage-in-LoggingEvent-tp20227123p20247920.html
Sent from the Log4j - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org