Page tree
Skip to end of metadata
Go to start of metadata

This filter simply logs the user making the request to the system. Place the filter directly behind the context filter if you would like to see every request made to the system. Otherwise place it where ever you would like based on your needs. 

package info.magnolia.groovy.filters;

import info.magnolia.context.MgnlContext;

import javax.servlet.FilterChain;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.ServletException;
public class LogUserFilter extends AbstractMgnlFilter {

    public static Logger log = LoggerFactory.getLogger(LogUserFilter.class);

    public void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
    throws IOException, ServletException {"Requesting User: " + MgnlContext.getUser().getName());

      chain.doFilter(request, response);
  • No labels