metacat
metacat copied to clipboard
Change logging behavior for NotAuthorized exceptions
catalina.out has become pretty hard to work with since MetacatUI sends cohorts of isAuthorized calls at Metacat as the user navigates around the site. And every time a client encounters a NotAuthorized exception, we print a full stack trace into catalina.out. For example: On arcticdata.io, NotAuthorized exceptions account for roughly 1,000,000 of 1,167,371 total lines of output.
To make our logs more useful, I suggest we:
- Change the log level for
NotAuthorizedexceptions to INFO - Don't print a stack trace with our log output
I think my change is achieved by:
diff --git src/edu/ucsb/nceas/metacat/restservice/D1ResourceHandler.java src/edu/ucsb/nceas/metacat/restservice/D1ResourceHandler.java
index 8f464128..cf6bdb33 100644
--- src/edu/ucsb/nceas/metacat/restservice/D1ResourceHandler.java
+++ src/edu/ucsb/nceas/metacat/restservice/D1ResourceHandler.java
@@ -53,6 +53,7 @@ import org.dataone.mimemultipart.MultipartRequestResolver;
import org.dataone.portal.PortalCertificateManager;
import org.dataone.service.exceptions.BaseException;
import org.dataone.service.exceptions.InvalidRequest;
+import org.dataone.service.exceptions.NotAuthorized;
import org.dataone.service.exceptions.NotFound;
import org.dataone.service.exceptions.ServiceFailure;
import org.dataone.service.types.v1.Group;
@@ -585,7 +586,7 @@ public class D1ResourceHandler {
// TODO: Use content negotiation to determine which return format to use
response.setContentType("text/xml");
response.setStatus(e.getCode());
- if( e instanceof NotFound) {
+ if( e instanceof NotFound || e instanceof NotAuthorized) {
logMetacat.info("D1ResourceHandler: Serializing exception with code " + e.getCode() + ": " + e.getMessage());
} else {
logMetacat.error("D1ResourceHandler: Serializing exception with code " + e.getCode() + ": " + e.getMessage(), e);
@taojing2002 could you take a look doing this for the next release of Metacat? I think it'd be a nice improvement.
@artntek This relates to our conversation the other day on logging verbosity and stack traces.