Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Logging *Business* Events - use logging framework?

Tags:

logging

events

Something here doesn't feel right to me here, and so I would like the community's input - perhaps I am approaching this in the wrong way....

Q: Is is appropriate to use traditional infrastructure logging frameworks (like log4net) to log business events?

When I say business events, I mean I want a global log like this:

xx:xx Customer A purchased widget B.
xx:xx Widget B was dispatched from warehouse.
xx:xx Customer B payment declined.

Most traditional infrastructure logging frameworks have event levels something like this:

FATAL
ERROR
WARN
INFO
DEBUG

An of course these messages don't fit well into that. Best description would be INFO, but of course these are important events, and INFO is of very low importance.

I would still like this as a 'log' (e.g. I don't want to have to extract this from my business objects each time I want to see it)

Seems to me I have two options:

1) Use a framework like log4net and just define a special logger for this (and live with the fact that it doesn't feel right).

2) Provide a service for performing this that doesn't rely on a traditional logging services.

I'm leaning towards 2. What has anyone else done in a similar situations?

Thanks!

like image 616
UpTheCreek Avatar asked Oct 27 '09 13:10

UpTheCreek


People also ask

What is Logger framework?

A logging framework is a utility specifically designed to standardize the process of logging in your application. This can come in the form of a third party tool, such as log4j or its . NET cousin, log4net. But a lot of organizations also roll their own.

Why should we use logging framework?

A logging framework is a tool that helps you standardize the process of logging in your application. Some languages provide a logging module in their standard library for this purpose, but most logging frameworks come in the form of third-party libraries such as log4j (Java), Zap (Go), or Winston (Node. js).

What is the difference between events and logs?

An event is a conceptual abstraction and a structured log is one possible representation of that abstraction. The interesting part of the conversation is where to draw the lines around that abstraction; the technical implementation part is how to represent that event.

Why do we need logging in Java?

In Java, logging is an important feature that helps developers to trace out the errors. Java is the programming language that comes with the logging approach. It provides a Logging API that was introduced in Java 1.4 version. It provides the ability to capture the log file.


2 Answers

What you're wanting sounds like an auditing service, not a logging service. If I'm right, your goals are to keep track of these business events for historical and maybe even reporting purposes. You can use the details in the audit to, for lack of a better phrase, place blame for events that happen in the system.

I probably wouldn't use a logging system, like log4j, for this purpose. In our system, auditing is a first class citizen as a full service.

-- HTH, Dusty

like image 109
dustyburwell Avatar answered Nov 15 '22 16:11

dustyburwell


Leave the logger for things having to do with the program, not the business. It is just a tool to help the developers.

Write your own system to log business events. If it is a business requirement to have a record, you will want something you have control over and you will need to use the logger above to keep track of how it works.

Basically, #2 in your question.

like image 38
Eric Normand Avatar answered Nov 15 '22 16:11

Eric Normand