Uploaded image for project: 'OpenMRS Core'
  1. OpenMRS Core
  2. TRUNK-3979

LoggingAdvice should also log which user is performing an action when an error occurs

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Should
    • Resolution: Fixed
    • Affects Version/s: OpenMRS 1.9.3
    • Fix Version/s: OpenMRS 1.9.4, Platform 1.10.0
    • Component/s: None
    • Labels:
    • Complexity:
      Low

      Description

      The org.openmrs.aop.LoggingAdvice class has code that logs any exception that happens, leading to something in your log file like:

      ERROR - LoggingAdvice.invoke(126) |2013-05-01 11:42:10,618| An error occurred while executing this method. Error message: You must have the role 'System Developer' in order to assign it.
      org.openmrs.api.APIException: You must have the role 'System Developer' in order to assign it.
              at org.openmrs.api.impl.UserServiceImpl.checkPrivileges(UserServiceImpl.java:430)
      ...
      

      Sometimes this is enough information, but usually it would help to know what user performed this action, so a sysadmin can follow up with them to understand what was going on at the time.

      This line should be changed to also log the authenticated user, if any:

      log.error("An error occurred while executing this method. Error message: " + t.getMessage(), t);
      

        Gliffy Diagrams

          Attachments

            Activity

              People

              Assignee:
              draggonz Zhaslan Doschanov
              Reporter:
              darius Darius Jazayeri
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - 2 hours
                  2h
                  Remaining:
                  Time Spent - 1 hour Remaining Estimate - 1 hour
                  1h
                  Logged:
                  Time Spent - 1 hour Remaining Estimate - 1 hour
                  1h