Skip to content

Commit

Permalink
Reduce logging level; add new log calls: #65
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cecilia-donnelly committed Jul 22, 2016
1 parent 72ce8af commit 0e7aa11
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/main/java/org/openhmis/webservice/ClientService.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public List<ClientDTO> 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;
}

Expand All @@ -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;
}

Expand All @@ -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
Expand All @@ -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;
}

Expand All @@ -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";
}
}
4 changes: 2 additions & 2 deletions src/main/resources/log4j.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
</appender>

<root>
<level value="DEBUG" />
<level value="INFO" />
<appender-ref ref="console" />
<appender-ref ref="file" />
</root>

</log4j:configuration>
</log4j:configuration>

0 comments on commit 0e7aa11

Please sign in to comment.