springboot配置日志
2020-12-22 14:27
标签:dmi run trigger stdout rgs environ time env size springboot配置日志 标签:dmi run trigger stdout rgs environ time env size 原文地址:https://www.cnblogs.com/bigdatadiary/p/13215438.html1、以eureka server启动类为例,将启动类改为以下内容:
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
import org.springframework.core.env.Environment;
/**
* @author Administrator
*/
@SpringBootApplication
@EnableEurekaServer
public class EurekaApplication {
private static final Logger LOG = LoggerFactory.getLogger(EurekaApplication.class);
public static void main(String[] args) {
SpringApplication app = new SpringApplication(EurekaApplication.class);
Environment env = app.run(args).getEnvironment();
LOG.info("Eureka启动成功,地址: \thttp://{}:{}", env.getProperty("eureka.instance.hostname"), env.getProperty("server.port"));
}
}2、添加logback.xml,在logback.xml中加入以下内容: