Skip to content

Instantly share code, notes, and snippets.

@benbpyle
Created March 23, 2019 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benbpyle/2fd34b4b1d94cb2e3801b8a98f56a91b to your computer and use it in GitHub Desktop.
Save benbpyle/2fd34b4b1d94cb2e3801b8a98f56a91b to your computer and use it in GitHub Desktop.
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