spring log code example
Example 1: spring logback configuration
@RestController
public class LoggingController {
Logger logger = LoggerFactory.getLogger(LoggingController.class);
@RequestMapping("/")
public String index() {
logger.trace("A TRACE Message");
logger.debug("A DEBUG Message");
logger.info("An INFO Message");
logger.warn("A WARN Message");
logger.error("An ERROR Message");
return "Howdy! Check out the Logs to see the output...";
}
}
Example 2: spring security logging
logging.level.org.springframework.security=DEBUG
Example 3: spring log properties
logging:
#pattern:
#file: %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%
file: app/application.log
level:
org:
springframework: INFO
hibernate:
SQL: INFO
type:
descriptor:
sql:
BasicBinder: INFO
web: DEBUG
com:
codeswifter: DEBUG
##logging.pattern.file= %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%
pattern:
console: :%d %5p [%-20.20t] %-35.35logger{15}:%-4.4L |%-15.15X{Email}|%-32.32X{UserId}| - %m%n
Example 4: spring security logging
logging:
level:
org:
springframework:
security: DEBUG