Hi
Recently I've faced such problem. I'm working on the application, in which logging is very important.
By logs in that application I mean the messages, like
- User A(id=x) has created invoice(invoice # is XXX) (1)
- User B(id=y) has purchased the book (2)
- User A(id=x) has approved invoice XXX (3)
(1) and (3) are messages of one particular request/command - so when I want to see the logs, I need to get all the information about this request log thread.
Because of the application is highly loaded and uses AJAX a lot, log message of different users/operations/requests can be mixed.
Temporary, I've fixed this problem like this:
I've created at the beginning of the request some unique UUID code, and prepend any log messages with this unique code. So, I can find all the messages of particular thread by simple grep UNIX command.
That solves the problem, but I'm not sure it is the best solution for the task. Looks more like reinventing the wheel. What solutions would you reccomend for this problem?