Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can use <a href="http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/NDC.html#push%28java.lang.String%29" rel="nofollow">NDC feature</a>. Set up some filter / interceptor (depends on what presentation technology you use). Add nested diagnostic context (filter example): </p> <pre><code>public class LogDiagnosticContextFilter implements javax.servlet.Filter { @Override public void init(FilterConfig filterConfig) throws ServletException { // do nothing } @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { SecurityContext context = SecurityContextHolder.getContext(); if (context != null) { Authentication authentication = context.getAuthentication(); if (authentication != null) { NDC.push("Username=" + authentication.getName()); } } chain.doFilter(request, response); NDC.pop(); } @Override public void destroy() { // do nothing } } </code></pre> <p>Ensure that filter executed after Spring Security filter chain (web.xml):</p> <pre><code>&lt;filter-mapping&gt; &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt; &lt;url-pattern&gt;/*&lt;/url-pattern&gt; &lt;/filter-mapping&gt; &lt;filter-mapping&gt; &lt;filter-name&gt;logDiagnosticContextFilter&lt;/filter-name&gt; &lt;url-pattern&gt;*&lt;/url-pattern&gt; &lt;/filter-mapping&gt; </code></pre> <p>Add <strong>x</strong> to each interested log4j pattern:</p> <pre><code>%x %d %p %t %c - %m%n </code></pre> <p>Later when you call</p> <pre><code>LOGGER.info("some text"); </code></pre> <p>anywhere in you code you will see</p> <pre><code>Username=corresponding_login some text </code></pre> <p>in your log</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload