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 Vivek Kapadekar <vk...@bitfone.com> on 2003/06/11 23:44:59 UTC
Duplicate Triggering of custom appender.
Hi
I have written my own simple appender ( this is the first time I am
writing an appender). I attach the appender to the Logger using
addAppender(). In my client class I log six messages, but what the
appenders append() method gets triggered 12 times. I thought it might
be due to the hierarchy , and the duplicate perhaps was made by the
rootLogger, but i have set the additivity flag to false, still I get
duplicate hits to my appender.
Can anybody shed light on this?
Thanks
--Vivek
Re: Duplicate Triggering of custom appender.
Posted by Vivek Kapadekar <vk...@bitfone.com>.
Hi
Below is the appender code. As you see there is not a lot of
implementation details in the appender. The append() method gets
triggered twice the number of times I log messages...
public class SOAPAppender extends AppenderSkeleton implements
org.apache.log4j.Appender {
/**
* A static Object that maintains message batch
*/
private static ArrayList messages = new ArrayList();
public static int hits = 0;
public SOAPAppender() {
super();
}
public void append(LoggingEvent parm1) {
Object obj = parm1.getMessage();
LogMessageBase logObj = null;
System.out.println(" Appender Triggered ");
hits++;
synchronized ( messages ) {
if ( messages.size() == 20 ) {
messages.add(obj);
System.out.println("Now make a soap call: with message list
size : " + messages.size()
+ " and clear the List of messages");
messages.clear();
}
else {
messages.add(obj);
}
}
System.out.println(" This was the " + hits + " hit. ");
/**@todo Implement this org.apache.log4j.AppenderSkeleton abstract
method*/
}
public boolean requiresLayout() {
return true;
}
public void close() {
/**@todo Implement this org.apache.log4j.Appender abstract method*/
}
}
On Wed, 2003-06-11 at 15:05, Yoav Shapira wrote:
Howdy,
It would be easier (for me at least ;)) to diagnose your problem if you post
the source code to your appender...
Yoav Shapira
--- Vivek Kapadekar <vk...@bitfone.com> wrote:
> Hi
> I have written my own simple appender ( this is the first time I am
> writing an appender). I attach the appender to the Logger using
> addAppender(). In my client class I log six messages, but what the
> appenders append() method gets triggered 12 times. I thought it might
> be due to the hierarchy , and the duplicate perhaps was made by the
> rootLogger, but i have set the additivity flag to false, still I get
> duplicate hits to my appender.
> Can anybody shed light on this?
>
> Thanks
>
> --Vivek
>
>
=====
Yoav Shapira
yoavs@computer.org
__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org
Re: Duplicate Triggering of custom appender.
Posted by Yoav Shapira <yo...@yahoo.com>.
Howdy,
It would be easier (for me at least ;)) to diagnose your problem if you post
the source code to your appender...
Yoav Shapira
--- Vivek Kapadekar <vk...@bitfone.com> wrote:
> Hi
> I have written my own simple appender ( this is the first time I am
> writing an appender). I attach the appender to the Logger using
> addAppender(). In my client class I log six messages, but what the
> appenders append() method gets triggered 12 times. I thought it might
> be due to the hierarchy , and the duplicate perhaps was made by the
> rootLogger, but i have set the additivity flag to false, still I get
> duplicate hits to my appender.
> Can anybody shed light on this?
>
> Thanks
>
> --Vivek
>
>
=====
Yoav Shapira
yoavs@computer.org
__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org