Skip to content
Browse files

added logs

  • Loading branch information...
1 parent f30af82 commit 0c9e31cb395eb1579d619dc606f17a6b3cc036fa @pyricau committed Apr 20, 2011
View
39 GwtTeaser/src/com/excilys/formation/gwt/teaser/server/LoggingServletFilter.java
@@ -0,0 +1,39 @@
+package com.excilys.formation.gwt.teaser.server;
+
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+
+public class LoggingServletFilter implements Filter {
+
+ @Override
+ public void destroy() {
+
+ }
+
+ private static final Logger logger = Logger.getLogger(LoggingServletFilter.class.getName());
+
+ @Override
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
+ if (request instanceof HttpServletRequest) {
+ HttpServletRequest httpRequest = (HttpServletRequest) request;
+ String user = httpRequest.getRemoteUser();
+ logger.log(Level.INFO, "Request from user: " + user);
+ }
+ chain.doFilter(request, response);
+ }
+
+ @Override
+ public void init(FilterConfig arg0) throws ServletException {
+
+ }
+
+}
View
2 GwtTeaser/war/WEB-INF/logging.properties
@@ -10,4 +10,4 @@
#
# Set the default logging level for all loggers to WARNING
-.level = WARNING
+.level = INFO
View
12 GwtTeaser/war/WEB-INF/web.xml
@@ -46,7 +46,7 @@
<param-value>true</param-value>
</init-param>
</filter>
-
+
<filter>
<filter-name>CAS HttpServletRequest Wrapper Filter</filter-name>
<filter-class>org.jasig.cas.client.util.HttpServletRequestWrapperFilter</filter-class>
@@ -57,6 +57,11 @@
<filter-class>org.jasig.cas.client.util.AssertionThreadLocalFilter</filter-class>
</filter>
+ <filter>
+ <filter-name>LogUserFilter</filter-name>
+ <filter-class>com.excilys.formation.gwt.teaser.server.LoggingServletFilter</filter-class>
+ </filter>
+
<filter-mapping>
<filter-name>CAS Authentication Filter</filter-name>
<url-pattern>/*</url-pattern>
@@ -81,6 +86,11 @@
<filter-name>CAS Assertion Thread Local Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
+
+ <filter-mapping>
+ <filter-name>LogUserFilter</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
<listener>
<listener-class>org.jasig.cas.client.session.SingleSignOutHttpSessionListener</listener-class>

0 comments on commit 0c9e31c

Please sign in to comment.
Something went wrong with that request. Please try again.