springboot配置日志

2020-12-22 14:27

阅读:738

标签:dmi   run   trigger   stdout   rgs   environ   time   env   size   

1、以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中加入以下内容:








%d{yyyy-MM-dd HH:mm:ss.SSS} %highlight(%-5level) %blue(%-50logger{50}:%-4line) %msg%n





${PATH}/trace.log

${PATH}/trace.%d{yyyy-MM-dd}.%i.log

10MB



%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %-50logger{50}:%-4line %green(%-8X{UUID}) %msg%n




${PATH}/error.log

${PATH}/error.%d{yyyy-MM-dd}.%i.log

10MB



%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %-50logger{50}:%-4line %green(%-8X{UUID}) %msg%n


ERROR
ACCEPT
DENY














springboot配置日志

标签:dmi   run   trigger   stdout   rgs   environ   time   env   size   

原文地址:https://www.cnblogs.com/bigdatadiary/p/13215438.html


评论


亲,登录后才可以留言!