Logging for the Open Web App Development

Log Appender for OWA Development

Hi All,

We are using the logging libraries for the Java based development. But AFAIK, We haven’t use any logging methods to the OWA development.

As the good practice, We should follow some logging manner to identify some critical issues. There are some advanced libraries for the JS based logging. Anyway, I have implemented a simple log appender to the System Administration OWA and I am logging every thing through this log Appender.


  • Easy to handle the log types in the OWA
  • Easy to control the log types which are going to print in the console through the log appender easily
  • I can modify the log pattern easily through the log appender easily
  • It may easy to generate a log file

Anyway, We should improve this log appender with some additional features :slight_smile: CC : @dkayiwa

Regards, Suthagar

1 Like

@suthagar23 thanks for the great initiative! :slight_smile:
Do you also have any, for those using React? cc @upendo @millicent @kingisaac95 @jeiddiah

1 Like

@dkayiwa We can look into this and see how to include logging into the OWAs we have worked on. Thank you @suthagar23

1 Like

@dkayiwa I just implemented for Angular JS. But some one can easily migrate this to React.

@upendo This is just an idea about the log appender. Using this appender we can easily control the OWA logging. I think you can easily implement this in React :slight_smile:

Thanks @suthagar23, I was able to build on your logger and implement it in the addon-manager OWA, I have a PR open here https://github.com/openmrs/openmrs-owa-addonmanager/pull/20, however your thoughts on this PR would be very much appreciated.

@suthagar23 can you share a link to the solution you implemented in Angular?

@kingisaac95 I just made it simple and there is a lot to improve :slight_smile:

Now we are implementing the logger on the client side. So storing the logs on the client side will be a huge blocker at this time.

Creating a log file in the server or storing the logs in the database will not be a possible solution for this scenario. because,

  1. We want to use another REST to create log file or store in the database. So what will be the solution if this REST call failed?
  2. We want to access the REST every time to store the logs. (Bulk transfer is not possible, because what can we do if there are any break points during that time duration?
  3. It may take some time to achieve this task using REST. So we can’t call the REST every time to transfer the logs to the server.(huge delay) So In my view, Using REST services again for the logging is not a good solution to achieve this task.

What is the Solution?

why we can’t use browser session/cookie for this purpose? Because server side doesn’t need this logs anymore. The developer or user who is working in the front end is only wanted this log by that time or after. So I just think about this idea,

  1. Store the logs into session/cookie(single or multiple) if logging is enabled.
  2. Create one common page for logs accessing which can contain the capability to retrieve the logs from the browser session/cookie.
  3. Improve that page to view as a logger or create a log file automatically (we can simply create a text file with the logs using JS)
  4. The user can get the immediate logs in their console. if the user wants to get some previous logs, he can just visit that page to get that logs. (Anymore if the session/cookie is lost - there are no way :slight_smile: )

I think It will be a simple and good way for the front-end developers and light weight implementation for the logger.

Note: We can create some algorithms to create multiple cookies for the logs. Because storing the huge logs into a single cookie is not possible. So we want to follow some multi cookie management here.

If you have any suggestions or idea, let’s discuss to improve this talk :slight_smile:

1 Like

Your idea for this sounds good. If I come with any other thing, I’ll tell you

@suthagar23, taking a step back, what is the “user story” behind what you’re doing here? Why are we storing logs?

E.g. one valuable thing is to track user behavior, to analyze how the app is being used. In this case you need to get those logs to the server side.

I don’t personally see much value in storing logs long-term on the client-side. Is it feasible for a typical end-user to find these and do something useful with them? Using browser db storage seems overkill for the small use cal…

@darius, The user story in my view is, If someone can’t get information through the OWA, then there might be server side or client side problems. We had server-side logs to analyze that problem but haven’t client-side logs for now. Here we totally depend on the REST services to run the OWA. If the REST is working fine, then there might be some problems on the client side. Because we are doing some sort of logic and some functionalities to improve the OWA experience from the client side using JS. So I thought, It is important to keep a logging facility in the front-end.

Actually, If we use the console for the logging when the user moves to another tap or any where it might be erased. So I planned to store anywhere to get the complete log.

E.g. one valuable thing is to track user behavior, to analyze how the app is being used. In this case, you need to get those logs to the server side.

This may be another use case of this implementation. We can track to improve the user experience :slight_smile: But Is it fine to send every log to server side using another REST calls?