title: How do I enable logging for Spring Security?
body: <p>I am setting up Spring Security to handle logging users in. I have logged in as a user, and am taken to an Access Denied error page upon successful login. I don't know what roles my user has actually been assigned, or the rule that causes access to be denied, because I can't figure out how to enable debugging for the Spring Security library.</p>
  
  <p>My security xml:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans ... &gt;
      &lt;!-- security --&gt;
  
      &lt;security:debug/&gt;&lt;!-- doesn't seem to be working --&gt;
  
      &lt;security:http auto-config="true"&gt;
  
          &lt;security:intercept-url pattern="/Admin**" access="hasRole('PROGRAMMER') or hasRole('ADMIN')"/&gt;
          &lt;security:form-login login-page="/Load.do"
              default-target-url="/Admin.do?m=loadAdminMain"
              authentication-failure-url="/Load.do?error=true"
              username-parameter="j_username"
              password-parameter="j_password"
              login-processing-url="/j_spring_security_check"/&gt;
          &lt;security:csrf/&gt;&lt;!-- enable Cross Site Request Forgery protection --&gt;
      &lt;/security:http&gt;
  
      &lt;security:authentication-manager&gt;
          &lt;security:authentication-provider&gt;
              &lt;security:jdbc-user-service data-source-ref="loginDataSource"
                  users-by-username-query="SELECT username, password, active FROM userinformation WHERE username = ?"
                  authorities-by-username-query="
                      SELECT ui.username, r.rolename 
                      FROM role r, userrole ur, userinformation ui 
                      WHERE ui.username=? 
                      AND ui.userinformationid = ur.userinformationid 
                      AND ur.roleid = r.roleid "
              /&gt;
              &lt;security:password-encoder hash="md5"/&gt;
          &lt;/security:authentication-provider&gt;
      &lt;/security:authentication-manager&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>I've also tried adding <code>log4j.logger.org.springframework.security=DEBUG</code> to my log4j.properties</p>
  
  <p>How can I get debug output for Spring Security?</p>