logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kuldeep Kumar <kuldeep.ku...@wellsfargo.com>
Subject Problem Identified - AsyncAppender with DBAppender.
Date Wed, 24 Aug 2005 18:23:46 GMT
I believe, I have identified some of the blocking problem that many, include 
me, have been seeing while using AsyncAppender with DBAppender. The issue that 
I was seeing is related to the code in DBAppender. I think there is still an 
issue with AsyncAppender that it is not able to continue once it hits a snag. 
When the DBAppender throws an exception, in my case, I noticed there were some 
valid messages that could have been written out, but were not. 

I was writing a message and its size was more than 4000 bytes and since the 
rendered_message in logging_event is defined as size 4000, it was throwing an 
exception "Data size bigger than max size for this type: 4802" at

 insertStatement.setString(3, event.getRenderedMessage());

I changed the code in DBAppender to look like 

      String renderedMessage = event.getRenderedMessage();
      if (renderedMessage.length() > 4000)
  		renderedMessage = renderedMessage.substring(0, 4000);

Similar change needs to be made for NDC field

String ndc = event.getNDC();
if (ndc.length > 4000)
	ndc = ndc.substring(0,4000)
insertStatement.setString(6, event.getNDC());

After I made the change the whole thing works like a charm. 
After playing around with the BufferSize a little bit, I was able to log 
around 10000 message in around 4 seconds, i.e. event/ 400 micro seconds, which 
is the kind of results I was hoping to see. 

I also stumbled across another error while testing "Async with DB" in a 
standalone application 

ORA-01000: maximum open cursors exceeded
ORA-04088: error during execution of trigger 'LOGO.LOGGING_EVENT_ID_SEQ_TRIG'

I haven't drilled too much into it, since my immediate concern is a web-app.

One other thing I tried is to to comment out the "getLogger().error("problem 
appending event", sqle);" statement in the catch block of append() method. 
This is the place where the dbAppender and in turn AsyncAppender thread seems 
to hang. That way the main thread won't block if there are event or database 
related issues. This will result in losing the events that were supposed to be 
logged, but this is better than if the main thread hangs and potentially 
affecting the application users. 

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

View raw message