[logback-user] Logging to database

Aswani sriaswani at gmail.com
Tue Jan 13 16:16:35 CET 2009


Hello Ralph,

This is a real requirement. We are trying user based logging. 

We tried the first option - writing to different files. Ours is a
distributed environment, and earlier they had some problem with files.
The second option we were asked to try is this - buffering all events of one
user and flush them at the end of the request. The need for buffering events
is, we need not commit each and every logging event to DB separately(which
is slow). At the end of the request we flush the complete buffer. And
"buffer per user" is because we want to have the logging events of one user
request as one clob data. 

So now, as we can have any appender encapsulated within SiftingAppender, I
just wanted to know, is there any Appender in Logback that suits this
requirement? Or can I create a small custom appender(which creates a buffer
for each user,provide basic functionalities and encapsulate that within
SiftingAppender) and at the end of the client request I can flush that
buffer? 

Currently we are using Log4j and jdk 1.4. We have plans of upgrading to
jdk1.5. 

Actually we started writing our own custom logging framework for this. But
few days back, I was suggested to have a look at Logback by Ceki. I just
wanted to know whether I can use Logback for my second option(buffer per
user and writing to DB). 

Suggestions are very much appreciated.
Thanks in advance!!!

Aswani


rgoers wrote:
> 
> 
> On Jan 12, 2009, at 8:50 AM, Aswani wrote:
> 
>>
>> Thank you Ceki.
>>
>> Is there any appender in Logback to buffer all events of one  
>> user(per client
>> request)?
>> Is the CyclicBufferAppender or WriterAppender suitable for this  
>> requirement?
>>
>> Yes, writing to Database is slower than writing to file. That the  
>> reason we
>> are thinking of buffering the events and write them at once as a  
>> single
>> message(clob data). We are also thinking of making this DB process
>> asynchronous.
> 
> I am curious as to why you want to buffer per user? Is that a real  
> requirement or are you just trying to figure out when to flush them?  
> The approach I have seen taken is to have a buffer with a fixed number  
> of records along with a timeout.  The timeout ensures that the buffer  
> doesn't sit there partly full for too long.
> 
> Buffering per request is a little difficult. You'd need to have a  
> buffer attached to a ThreadLocal so that it can be located without  
> requiring the Request object. But if the request thread does work on  
> another thread as well things would get messy. Plus, the appender  
> can't really know when to flush the buffer without the application  
> forcing it.
> 
> Ralph
> _______________________________________________
> Logback-user mailing list
> Logback-user at qos.ch
> http://qos.ch/mailman/listinfo/logback-user
> 
> 

-- 
View this message in context: http://www.nabble.com/Logging-to-database-tp21417555p21437723.html
Sent from the Logback User mailing list archive at Nabble.com.



More information about the Logback-user mailing list