Created
March 23, 2019 14:18
-
-
Save benbpyle/2fd34b4b1d94cb2e3801b8a98f56a91b to your computer and use it in GitHub Desktop.
SLF4J logging example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.logging-example | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.http.ResponseEntity; | |
import org.springframework.web.bind.annotation.*; | |
@RestController | |
@RequestMapping("/logging-example") | |
public class LoggingController { | |
// declare the SLF4J logger | |
private Logger logger = LoggerFactory.getLogger(LoggingController.class); | |
@GetMapping | |
public ResponseEntity<String> get() { | |
// log an info message | |
logger.info("An info message"); | |
return ResponseEntity.ok("Hello world"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment