zoukankan      html  css  js  c++  java
  • java spring boot 写入日志

    java spring boot 写入日志

    1 配置文件

    logging.file=myLog.log
    logging.level.root=INFO

    2 代码

    package com.example.demo2122;
    import org.springframework.amqp.core.AmqpTemplate;
    import org.springframework.amqp.rabbit.annotation.RabbitHandler;
    import org.springframework.amqp.rabbit.annotation.RabbitListener;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.scheduling.annotation.Async;
    import org.springframework.scheduling.annotation.Scheduled;
    import org.springframework.stereotype.Component;
    import org.springframework.web.bind.annotation.GetMapping;
    import org.springframework.web.bind.annotation.RequestParam;
    import org.springframework.web.bind.annotation.RestController;
    
    import org.slf4j.*;
    
    
    @RestController
    public class HelloControl {
        Logger logger = LoggerFactory.getLogger(getClass());
    
        @GetMapping("/hello")
        public String hello(@RequestParam(value = "name", defaultValue = "World") String name) {
    
    
            logger.error("这是 error");
    
            return "success";
        }
    
    
    
    }

    显示控制台

    日志文件

  • 相关阅读:
    8.11记---我来啦!
    关于博主
    CSP-S 2019 第二轮 游记 AFO
    读入优化
    CSP-S 2019 第一轮 游记
    2019国庆正睿成都集训
    成外集训小记
    收藏夹(持续更新)
    博客建成
    博客施工中,敬请期待
  • 原文地址:https://www.cnblogs.com/newmiracle/p/12752295.html
Copyright © 2011-2022 走看看