zoukankan      html  css  js  c++  java
  • SpringBoot--logger日志配置,使用@Slf4j注解

    1、添加依赖:log4j的依赖在springboot下已经提供了

    <!--定时任务和@Slf4j注解日志的依赖-->
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <optional>true</optional>
    </dependency>

    2、在需要生成日志的类上添加@Slf4j,即可直接使用log生成日志,更为方便

    package com.example.demo.Log;
    
    import lombok.extern.slf4j.Slf4j;
    import org.junit.Test;
    import org.junit.runner.RunWith;
    import org.springframework.boot.test.context.SpringBootTest;
    import org.springframework.test.context.junit4.SpringRunner;
    
    /**
     * @author 王慧
     * @description 日志
     * @date 2020/1/8
     */
    @RunWith(SpringRunner.class)
    @SpringBootTest
    @Slf4j
    public class SpringbootLoggerApplicationTests {
    
        @Test
        public void contextLoads() {
        }
    
        @Test
        public void logger() {
            log.info("=====>>>>> logger()");
        }
    }

    3、下载安装lombok的插件

    Ctrl+Alt+S打开Settings

    
    
  • 相关阅读:
    markdown文件的基本常用编写
    寒假作业安排及注意点
    Day2
    Day1
    Python格式化
    Python 遍历字典的键值
    python 判断是否为空
    git 回退版本
    Python获取当前文件夹位置
    Python3, Python2 获取当前时间
  • 原文地址:https://www.cnblogs.com/wangdahui/p/12168476.html
Copyright © 2011-2022 走看看