Skip to content

Commit 07efe8d

Browse files
committed
Refactored logging to slf4j
1 parent 0dad55c commit 07efe8d

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

Ch04_OutputEscapingJSP/pom.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@
2828
<artifactId>jstl</artifactId>
2929
<version>1.2</version>
3030
</dependency>
31+
<dependency>
32+
<groupId>org.slf4j</groupId>
33+
<artifactId>slf4j-api</artifactId>
34+
</dependency>
35+
<dependency>
36+
<groupId>org.slf4j</groupId>
37+
<artifactId>slf4j-log4j12</artifactId>
38+
</dependency>
3139
<dependency>
3240
<groupId>log4j</groupId>
3341
<artifactId>log4j</artifactId>

Ch04_OutputEscapingJSP/src/main/java/de/dominikschadow/webappsecurity/controller/ContactController.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
package de.dominikschadow.webappsecurity.controller;
2020

2121
import de.dominikschadow.webappsecurity.domain.Contact;
22-
import org.apache.log4j.Logger;
22+
import org.slf4j.Logger;
23+
import org.slf4j.LoggerFactory;
2324
import org.springframework.stereotype.Controller;
2425
import org.springframework.validation.BindingResult;
2526
import org.springframework.web.bind.annotation.ModelAttribute;
@@ -35,11 +36,11 @@
3536
@Controller
3637
@SessionAttributes
3738
public class ContactController {
38-
private static final Logger LOGGER = Logger.getLogger(ContactController.class);
39+
private Logger logger = LoggerFactory.getLogger(getClass());
3940

4041
@RequestMapping(value = "/addContact", method = RequestMethod.POST)
4142
public ModelAndView addContact(@ModelAttribute("contact") Contact contact, BindingResult result) {
42-
LOGGER.info("Firstname: " + contact.getFirstname() + ", Lastname: " + contact.getLastname());
43+
logger.info("Firstname: " + contact.getFirstname() + ", Lastname: " + contact.getLastname());
4344

4445
return new ModelAndView("contact", "command", contact);
4546
}

0 commit comments

Comments
 (0)