
Hi everyone, In our application we log all events of all users to one log file. As we have many users, suppprt has become difficult. So we are exploring better ways. we have two options: 1) Seperating logging to different files, like one file per user. - There is a SiftingAppender in logback that serves this purpose. 2) Logging to database. (Our team is interested in this option) - Not one event at a time. Buffering all events of one client request and write all those buffered messages as one single string to Database at the end of the request. So the buffer should be thread local, or one buffer per user. I am just wondering is this possible with SiftingAppender? I saw CyclicBufferAppender in logback apidocs. But there is no documentation for that. If this appender is not for that purpose, Is there any appender that suits my requirement? So, I am thinking, instead of a FileAppender in the SiftingAppender, can we have any other appender that buffers all logging events of one client request? Am I thinking in the right direction?... Please help me in this regard... Thanks in advance!!! Aswani -- View this message in context: http://www.nabble.com/Logging-to-database-tp21417555p21417555.html Sent from the Logback User mailing list archive at Nabble.com.

Hello Aswani, SiftingAppender can help you separate logging output per user, for example to separate files. However, it can also be used to encapsulate any other kind of appender, not just FileAppender. You could in principle create an appender which collects logging entries belonging to a user and then writing the results as a database entry. SiftingAppender can deal with such an appender. Note that by logging into a database, assuming you have MDC data, you can perform SQL operations (select) resulting in the logs for a designated user. However, logging to a database is slower than writing to a file. Aswani wrote:
Hi everyone,
In our application we log all events of all users to one log file. As we have many users, suppprt has become difficult.
So we are exploring better ways.
we have two options:
1) Seperating logging to different files, like one file per user. - There is a SiftingAppender in logback that serves this purpose.
2) Logging to database. (Our team is interested in this option) - Not one event at a time. Buffering all events of one client request and write all those buffered messages as one single string to Database at the end of the request. So the buffer should be thread local, or one buffer per user. I am just wondering is this possible with SiftingAppender? I saw CyclicBufferAppender in logback apidocs. But there is no documentation for that. If this appender is not for that purpose, Is there any appender that suits my requirement?
So, I am thinking, instead of a FileAppender in the SiftingAppender, can we have any other appender that buffers all logging events of one client request?
Am I thinking in the right direction?...
Please help me in this regard... Thanks in advance!!!
Aswani
-- Ceki Gülcü Logback: The reliable, generic, fast and flexible logging framework for Java. http://logback.qos.ch

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. Thanks in advance!!! Aswani Ceki Gulcu wrote:
Hello Aswani,
SiftingAppender can help you separate logging output per user, for example to separate files. However, it can also be used to encapsulate any other kind of appender, not just FileAppender. You could in principle create an appender which collects logging entries belonging to a user and then writing the results as a database entry. SiftingAppender can deal with such an appender.
Note that by logging into a database, assuming you have MDC data, you can perform SQL operations (select) resulting in the logs for a designated user. However, logging to a database is slower than writing to a file.
Aswani wrote:
Hi everyone,
In our application we log all events of all users to one log file. As we have many users, suppprt has become difficult.
So we are exploring better ways.
we have two options:
1) Seperating logging to different files, like one file per user. - There is a SiftingAppender in logback that serves this purpose.
2) Logging to database. (Our team is interested in this option) - Not one event at a time. Buffering all events of one client request and write all those buffered messages as one single string to Database at the end of the request. So the buffer should be thread local, or one buffer per user. I am just wondering is this possible with SiftingAppender? I saw CyclicBufferAppender in logback apidocs. But there is no documentation for that. If this appender is not for that purpose, Is there any appender that suits my requirement?
So, I am thinking, instead of a FileAppender in the SiftingAppender, can we have any other appender that buffers all logging events of one client request?
Am I thinking in the right direction?...
Please help me in this regard... Thanks in advance!!!
Aswani
-- Ceki Gülcü Logback: The reliable, generic, fast and flexible logging framework for Java. http://logback.qos.ch _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://qos.ch/mailman/listinfo/logback-user
-- View this message in context: http://www.nabble.com/Logging-to-database-tp21417555p21418376.html Sent from the Logback User mailing list archive at Nabble.com.

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

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@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.
participants (3)
-
Aswani
-
Ceki Gulcu
-
Ralph Goers