springboot自带日志slf4j使用

摘要:
importcom.icloudmap.utils.webui.ResultMessage;importorg.slf4j.Logger;importorg.slf4j.LoggerFactory;importorg.springframework.web.bind.annotation.RequestMapping;importorg.springframework.web.bind.annot
import com.icloudmap.utils.webui.ResultMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
/**
* 测试
*/
@RestController()
@RequestMapping("/test")
public class TestController {
Logger logger = LoggerFactory.getLogger(TestController.class);
@ResponseBody
@RequestMapping("/helloWorld")
public ResultMessage helloWorld() {
ResultMessage res = new ResultMessage();
res.setSuccess(true);
res.setMsg("hello world !");
logger.info("test controller");
return res;
}
}
application.properties 配置文件:
logging.file=./log/materialized.log
# 按256Mb切分日志,不配置的话,默认10mb
logging.file.max-history=20
#必须要该路径,不然无法切分日志
logging.path=./log/
logging.file.max-size=256MB
logging.pattern.console=%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger- %msg%n
logging.pattern.file=%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n

免责声明:文章转载自《springboot自带日志slf4j使用》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇Jmeter从数据库中读取数据Beyond Compare如何展开所有子文件夹下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

注解@Slf4j

如果不想每次都写private final Logger logger = LoggerFactory.getLogger(XXX.class); 可以用注解@Slf4j 一、在pom文件加入依赖 <dependency><groupId>org.projectlombok</groupId><artifactId...

zookeeper-分布式协调工具(一),java操作zookeeper

什么是zookeeper 1.Zookeeper是一个分布式开源框架,提供了协调分布式应用的基本服务,它向外部应用暴露一组通用服务——分布式同步、命名服务、集群维护等,简化分布式应用协调及其管理的难度,提供高性能的分布式服务。ZooKeeper本身可以以单机模式安装运行,不过它的长处在于通过分布式ZooKeeper集群,基于一定的策略来保证ZooKeepe...

SpringBoot如何使用Slf4j日志与logback-spring.xml配置详解

一、SpringBoot如何使用Slf4j日志   springboot是默认使用slf4j进行日志管理的,所以集成也比较方便。 1、添加依赖 (1)spring-boot-starter-web依赖,用于自动导入日志框架的依赖 <dependency> <groupId>org.springframework.boot&l...

Underlying cause: java.sql.SQLException : Access denied for user 'root'@'s150' (using password: YES)

hive初始化元数据的时候出错,该root用户没有权限 [xiaoqiu@s150 /soft/hive/conf]$ schematool -initSchema -dbType mysql SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:f...