Registration of user actions

The client wants us to "log" the actions that the user performs on our system: create, delete and update, basically. I already have an aspect that logs a trace, but works at a rather low level of logging every method call. Therefore, if the user clicks on the "open medical file" button, the log will read:

  • closePreviousFiles ("zero zero")
  • createMedicalFile ("patient-zero") → file # 001
  • changeStatus ("# 001") → open

while the desired result is:

  • opened medical file no. 001 for the patient

I'm thinking about Struts2 action tools with log statements, but I'm wondering ... is there any other way to do this? I could use AspectJ (or a filter) again and only keep the logic in one place so that I can easily customize the log, but then I'm afraid things will get harder to understand (ie "The log for this action is wrong" ... where the hell am I supposed to look for problems? ").

+1


source to share


4 answers


It looks like your client wants an audit trail of the user's actions on the system.

Note that at each entry point for an action (from a web request) to trigger an enumerated / constant audit record in the action. Fill it in with the information provided by the user if possible.

On exit / finalize, indicate in the audit whether it will succeed or fail. An example in pseudocode:



enum Actions {
  OPEN_MEDICAL_FILE
  ...
}

void handleRequest(...) {
  String patient = ...;
  Audit audit = new Audit(OPEN_MEDICAL_FILE);
  audit.addParameter("patient", patient);
  try {
     ... more things ..
     audit.addParameter("file", "#001");
     ... more things ...
     audit.setSuccess();
  } finally {
    audit.save();
  }
}

      

The important thing is that all user actions are saved regardless of success or failure. In addition, the client really needs to know all the necessary information along with the action.

Because we are logging action constants and data, the audit view to the client can be separately coded. You also get flexibility because changing the view string (for example, "open medical file # 001 for patient with zero" to "patient with zero # 001 medical file open") is not detected during action, but later. t you need to delete the audit data.

+2


source


I recently processed the logs to create a summary. You might consider this approach, especially if # 2 and # 3 in the above logs are generated in different locations and the desired result would require transferring state from one location to another.



+1


source


If you are working with medical data, you might want to consider both journal and version control. I would even think about it with database triggers. I am not into Java programming, but I discussed this issue with our student information system team. They use Oracle on the server and register a session variable with their connections. Their triggers use this session variable to create log records and version history (on update / delete) of critical tables. This gives them audit and rollback capabilities. I would have thought that both would be useful for medical records.

They also use log4j for application level logging, but the data logging happens to the database.

+1


source


I did similar stuff in Struts2 actions, I used "log4j". Depending on your application server, it may have an integrated logging system that allows you to use message catalogs (like Weblogic).

+1


source







All Articles