I have a web application written in Java, Oracle, and AngularJS. I want to save log in database when user changes, creates or updates something.
There are two way of implementing this:
1. Auditing tables via Triggers
Cons: On database level I don't have user information who makes changes, so I have to save userName in every table I make any change.
For example: my table will look like this:
my_table {
field_1,
field_2,
...,
userName
)
2. Adding event logging functionality in Web application API functions
For example, when user changes data I have to call both functions: changeObject
and AuditUserChange
.
In addition to this I have to add trigger on the table to save audit log when somebody (support specialist) makes any change directly in database tables.
Which strategy should I use? Which option is better?