Kotlin
logback
logger
spring-boot

Spring Boot in KotlinでLoggerの宣言方法が分からなかった時のメモ

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class CardatabaseApplication {
  private static final Logger logger = LoggerFactory.getLogger(CardatabaseApplication.class);
  public static void main(String[] args) {
    SpringApplication.run(CardatabaseApplication.class, args);
    logger.info("Hello Spring Boot");
  }
}
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication

@SpringBootApplication
class CardatabaseApplication

val logger: Logger = LoggerFactory.getLogger(CardatabaseApplication::class.java)
fun main(args: Array<String>) {
    runApplication<CardatabaseApplication>(*args)
    logger.info("Hello Spring Boot")
}

参考

  • Hands-On Full Stack Development with Spring Boot 2.0 and React(Packt)
  • sdeleuze/spring-boot-kotlin-demo(GitHub)