From 0e7aa11a0607dac1a88adf7b2346b213e6b150d1 Mon Sep 17 00:00:00 2001 From: cecilia-donnelly Date: Fri, 22 Jul 2016 16:45:14 -0500 Subject: [PATCH] Reduce logging level; add new log calls: #65 Add more logging calls to the clients endpoint. Next I'll add these to the rest of the endpoints. The Log4J config file determines how detailed to get in the logging. INFO is slightly less detailed than DEBUG, so with this change we'll get less logging output total (in both catalina.out and OpenHMIS.log), but we will get all the INFO calls we add to the endpoints. Each level is inclusive of the more severe levels, so now that we've set the logging level to INFO we'll see everything in the INFO, WARN, ERROR, and FATAL categories, but not the lower level categories (TRACE and DEBUG). See https://logging.apache.org/log4j/2.x/manual/configuration.html for more. For future debugging we can always change the logging level in log4j.xml to show more detail (e.g., back to DEBUG). For now, though, using INFO should reduce the amount of logging, as requested in #72. --- src/main/java/org/openhmis/webservice/ClientService.java | 8 ++++++-- src/main/resources/log4j.xml | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/openhmis/webservice/ClientService.java b/src/main/java/org/openhmis/webservice/ClientService.java index 2e71999..fd528ca 100644 --- a/src/main/java/org/openhmis/webservice/ClientService.java +++ b/src/main/java/org/openhmis/webservice/ClientService.java @@ -53,7 +53,7 @@ public List getClients(@HeaderParam("Authorization") String authoriza format, some conventions, and maybe a helper class to enforce it all; would also be nice to log which user made the request. But for now, just show that logging works. */ - log.debug("GET /clients/ (" + clientDTOs.size() + " results)"); + log.info("GET /clients/ (" + clientDTOs.size() + " results)"); return clientDTOs; } @@ -65,6 +65,7 @@ public ClientDTO createClient(@HeaderParam("Authorization") String authorization if(!Authentication.googleAuthenticate(authorization, Authentication.WRITE)) throw new AccessDeniedException(); ClientDTO outputVO = clientManager.addClient(inputVO); + log.info("POST /clients/ (ID: " + outputVO.getId() + ")"); return outputVO; } @@ -75,7 +76,8 @@ public ClientDTO getClient(@HeaderParam("Authorization") String authorization, @ if(!Authentication.googleAuthenticate(authorization, Authentication.READ)) throw new AccessDeniedException(); ClientDTO clientDTO = clientManager.getClientByPersonalId(personalId); - return clientDTO; + log.info("GET /clients/" + personalId); + return clientDTO; } @PUT @@ -88,6 +90,7 @@ public ClientDTO updateClient(@HeaderParam("Authorization") String authorization inputVO.setPersonalId(personalId); ClientDTO outputVO = clientManager.updateClient(inputVO); + log.info("PUT /clients/" + personalId); return outputVO; } @@ -98,6 +101,7 @@ public String deleteClient(@HeaderParam("Authorization") String authorization, @ if(!Authentication.googleAuthenticate(authorization, Authentication.WRITE)) throw new AccessDeniedException(); clientManager.deleteClient(personalId); + log.info("DELETE /clients/" + personalId); return "true"; } } diff --git a/src/main/resources/log4j.xml b/src/main/resources/log4j.xml index 7358251..cf98277 100644 --- a/src/main/resources/log4j.xml +++ b/src/main/resources/log4j.xml @@ -22,9 +22,9 @@ - + - \ No newline at end of file +