Let's say I need two logs coming out of my application. One is for debugging issues and making sure the application runs correctly and the other is used for user statistics and general analysis of the entire interaction. The latter should include enough information to spot bottlenecks and the entire behavior per user.
First of all, how would you call each log? Are they both called a "log"? Is one an audit log? What's the correct professional terminology for each?
Second of all, how would you design the statistics log?
In Python for example, I can use the logging module to insert random logging.info
or logging.debug
calls for the application log, quite about anywhere, and even if some information will be missed, it's not an issue.
The statistics log though needs to keep a unique session id for example, all throughout the program. This causes design issues and forces me to either put it globally per thread or pass it around just about everywhere, even for entirely decoupled utility modules, and thus ruins the architectural layers. I might need raw data from the sockets for the statistics, and I might need high application-tier data too, wrecking quite a havoc as of where to put the logging lines, where to put some per-request identifiers like session id, and whether some layers or decoupled modules should even be aware of the request (in case I need some internal statistics showing the operation of the decoupled modules under each request).
Statistic log should also be machine parsable ofc, so would you even use the python logging
module for that?
Bottom line, is there any general idiom to design those logs?
banana
is in the request or not is independend from the id. Each service would log separately and with the correlation id, you would find, which things belong together. – Thomas Junk May 2 '18 at 13:59