Skip to content

Instantly share code, notes, and snippets.

@benbpyle
Created March 23, 2019 14:18
Embed
What would you like to do?
SLF4J logging example
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