Skip to content

Commit

Permalink
switch to log4j version 2 and fishtag added
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelwechner committed Sep 13, 2013
1 parent 5ccf898 commit 158e5d2
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/webapp/src/java/org/wyona/yanel/servlet/YanelServlet.java
Expand Up @@ -101,6 +101,9 @@
import org.wyona.security.core.api.User;

import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.ThreadContext;

import org.apache.xalan.transformer.TransformerIdentityImpl;
import org.apache.xml.resolver.tools.CatalogResolver;
import org.apache.xml.serializer.Serializer;
Expand All @@ -124,11 +127,12 @@
import org.quartz.impl.StdSchedulerFactory;

/**
* Main entry of Yanel webapp
* Main entry point of Yanel webapp (see method 'service')
*/
public class YanelServlet extends HttpServlet {

private static Logger log = Logger.getLogger(YanelServlet.class);
private static org.apache.logging.log4j.Logger log = LogManager.getLogger(YanelServlet.class);

private static Logger logAccess = Logger.getLogger(AccessLog.CATEGORY);
private static Logger logDoNotTrack = Logger.getLogger("DoNotTrack"); // INFO: For debugging only!
private static Logger log404 = Logger.getLogger("404");
Expand Down Expand Up @@ -318,6 +322,7 @@ public void init(ServletConfig config) throws ServletException {
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// NOTE: Do not add code outside the try-catch block, because otherwise exceptions won't be logged
try {
ThreadContext.put("id", "fishtag");
//String httpAcceptMediaTypes = request.getHeader("Accept");
//String httpAcceptLanguage = request.getHeader("Accept-Language");

Expand Down Expand Up @@ -400,6 +405,8 @@ protected void service(HttpServletRequest request, HttpServletResponse response)
} catch (IOException e) {
log.error(e, e);
throw new IOException(e.getMessage());
} finally {
ThreadContext.clear();
} // NOTE: This was our last chance to log an exception, hence do not add code outside the try-catch block
}

Expand Down

0 comments on commit 158e5d2

Please sign in to comment.