Access logging in database [message #1202659] |
Fri, 22 November 2013 03:52  |
Eclipse User |
|
|
|
Hi,
I have a requirement that it must be clear who read and/or changed some particular data.
For this I want to log every read / insert and update to particular data. I think of adding some generic logging that logs to a database. At least I must log the dateTime, the user, the object involved and the changed data.
I don't have to log all access only those that involve some medical data.
What would be the best way to do this in Scout.
Regards Bertin
|
|
|
|
|
Re: Access logging in database [message #1209601 is a reply to message #1209095] |
Mon, 25 November 2013 11:00  |
Eclipse User |
|
|
|
Our project has a similar requirement. The difference is, that updates through other clients such as SQLDeveloper have to be recorded as well. In this case it is impossible to implement a solution in Scout alone. Also, we don't have to record a SELECT.
The database supports triggers. We're using the triggers to record the update / insert / delete of data. Since the database does not know which user is issuing the updates through the Scout server, we also use a transaction specific variable to store the username and record it with every trigger execution.
In the SQLService:
@Override
protected void execBeginTransaction() throws ProcessingException {
SQL.callStoredProcedure("CALL trg_audit_pack.set_scout_session(:user)", new NVPair("user", ServerSession.get().getUserId()));
}
@Override
protected void execEndTransaction(boolean willBeCommitted) throws ProcessingException {
SQL.callStoredProcedure("CALL trg_audit_pack.clear_scout_session()");
}
Logging at the servicetunnel sounds like a great idea at first, but it runs into trouble when a service calls another service on the backend; those calls don't go through the servicetunnel.
If your requirements are not that strict and you would just like to log every time a specific type of data is sent through the tunnel you might find the DefaultTransactionDelegate useful.
|
|
|
Powered by
FUDForum. Page generated in 0.03410 seconds