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";
        }
    
    
    
    }

    显示控制台

    日志文件

  • 相关阅读:
    Unity
    Unity
    Unity
    Unity
    Unity项目
    Unity
    UnityShader
    Unity
    【数据结构与算法】链表——奇偶链表
    【数据结构与算法】链表——分隔链表
  • 原文地址:https://www.cnblogs.com/newmiracle/p/12752295.html
Copyright © 2011-2022 走看看