开发者

Advice on e-commerce logging strategy

开发者 https://www.devze.com 2022-12-26 08:04 出处:网络
I recently inherited an e-commerce app (Java/Struts) that I\'m porting to Rails. The thing is, we frequently have to do forensics on orders by poring through the log files, and with the old app\'s l

I recently inherited an e-commerce app (Java/Struts) that I'm porting to Rails.

The thing is, we frequently have to do forensics on orders by poring through the log files, and with the old app's logs (log4j wall of text) it's pretty hard to make sense of the individual orders when several people are pl开发者_如何学运维acing orders simultaneously.

So I'm soliciting advice on a good strategy for logging of these orders, like maybe logging each individual order to its own MongoDB collection based on unique cart ID? Or maybe group them by IP address? Something different entirely?

Essentially, what is the best approach for logging of an online store so that it's easy to backtrace each user's interaction with the site?


You shouldn't log each order to its own collection, as collections incur too much overhead. I'd have a single collection containing all interactions. The decide if you want to store one or multiple documents per order. If you store just one document per order, that document can contain an array of 'interaction' documents. It's easy to push another interaction onto each document.

If you're going to do lots of slicing and dicing of interactions, then I'd say one document per action, adding the appropriate indexes for the kinds of queries you'll be doing.

0

精彩评论

暂无评论...
验证码 换一张
取 消