Task: log login attempts. I use log4j2 and Spring Security / MVC, before that I used filters and servlets. I used to just logging in a servlet, how to implement this in spring?

PS There is an assumption to catch in the controller / j_spring_security_check, and there to write to the log, but I do not fully understand how to do it.

  • I read this doc, but there is about the first log4j, and also, as I understand it, there is an example for debugging, and not for logging events. If not correct, please correct - GermanSevostyanov
  • The meaning does not change, only write the configuration for the second version, not for the first. Here javabeat.net/log4j-2-spring-mvc is an example configuration and how to use MVC in general. The insides of SpringMVC should also be logged, not sure how much detail. - Vartlok
  • Thank you very much, you can make your comment as an answer and I will mark it true - GermanSevostyanov

1 answer 1

To enable logging, you need to add a configuration file, in your case log4j2 in the classpath. An example of the file and full logging settings can be found here.