7

Are there any design patterns or best practices around logging events for use in reporting and BI systems.

For example in a system which manages orders from a website, it would be beneficial if a customer support worker could type in an order number and see that it the order was placed on a certain day, dispatched on a certain day and delivered on another.

I can see 2 ways around this. I have an order object which has the fields:

OrderDate
DespatchDate
DeliveryDate

and populate them if they have happend otherwise they will be null

OR

log some sort of events like which are messages like:

Order Number - "12312312" - Ordered on '2014/01/01'
Order Number - "12312312" - Despatched on '2014/01/01'

and add store the events in a database.

Are there any guidelines for this? For example how does the work item history in TFS work?

TFS History

8

Robert made good points in his answer.

In addition, you might want to look at Audit Log as described by Martin Fowler here (and perhaps, more generally, Temporal Patterns). If you wanted to do more than just business activity monitoring / business reporting of these events, you might want to look at Event Sourcing. Fowler provides an introduction here.

You can use these terms to search for other opinions on the web.

  • 1
    Audit Log is exactly the term I was looking for. – Nick Williams May 3 '14 at 19:31
  • Martin Fowler seems to have deleted the content from that Audit Log article some time in 2014. Thankfully, web.archive.org has a copy of what it looked like on 2014-04-13. – Jeff Jan 7 '15 at 15:19
6

If this is an actual business-related report that is going to be generated and given to someone, then generate event records into a database, and then create a report from those records. Give the records actual semantic meaning, rather than merely attaching a message. In other words, make them first-class citizens.

Logging serves a different purpose. Logging is intended as a systems monitoring tool, not a business logic mechanism. If the report is an integral part of running the business, then make it an integral part of the application.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.