Data logged to a file; how do I rotate logs and how do I parse the data to not have 'gaps' in the da

Posted by phidah on Stack Overflow See other posts from Stack Overflow or by phidah
Published on 2010-03-23T12:16:08Z Indexed on 2010/04/03 16:53 UTC
Read the original article Hit count: 322

Filed under:
|
|
|

I've got a web application that, for performance reasons, throws any data sent into a logfile.

I've got two concerns with this approach:

  1. How do I best rotate logs, in order to not lose data?
  2. For each user session multiple requests are logged. Each request has a unique id so there is an easy way for me to tie the requests to the session. The problem is, however, that if I rotate the logs I risk ending up with one request in one log and another request in another log.

How do I arrange my parsing in a way that allows me to parse all requests from a given session? I am willing to define a session timelimit, for example that the requests must, at maximum be 30 minutes apart.

If I had a hourly log rotation at 00 minutes:

What if the user made one request at 13:59 and one at 14:01 - The user would end up having requests in two different logs.

© Stack Overflow or respective owner

Related posts about logging

Related posts about parsing