• log4j


    pom.xml

    <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
    <exclusions>
    <exclusion>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-logging</artifactId>
    </exclusion>
    </exclusions>
    </dependency>
    <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-log4j</artifactId>
    <version>1.3.8.RELEASE</version>
    </dependency>

    log4j.properties

    log4j.rootLogger = INFO, console

    log4j.appender.stdout = org.apache.log4j.ConsoleAppender
    log4j.appender.stdout.Threshold = DEBUG
    log4j.appender.stdout.Target = System.out
    log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
    log4j.appender.stdout.layout.ConversionPattern = [%-5p] %d{yyyy-MM-dd HH:mm:ss,SSS} method:%l%n%m%n


    log4j.appender.D = org.apache.log4j.DailyRollingFileAppender
    log4j.appender.D.File = D://log.log
    log4j.appender.D.Append = true
    log4j.appender.D.Threshold = WARN
    log4j.appender.D.layout = org.apache.log4j.PatternLayout
    log4j.appender.D.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n

    application.properties

    logging:
    config: src/main/resources/log4j.properties

    .java

    public class ClientStarter {
    private static org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(ClientStarter.class);

    public static void main(String[] args) {
    ClientStarter.class.getClassLoader().getResourceAsStream("log4j.properties");


    log.debug("haha, this is log4j debug");
    log.info("haha, this is log4j info");
    log.warn("haha, this is log4j warn");
    log.error("haha, this is log4j error");

    SpringApplication.run(ClientStarter.class);
    }

    https://blog.csdn.net/sinat_30185177/article/details/73550377

  • 相关阅读:
    线段树(题集
    T3——拆分自然数
    P1309 瑞士轮
    普通母函数简单使用
    双向广度优先搜索
    秦九韶算法
    P1043-数字游戏
    网站在阿里云备案的详细全过程详细步骤
    从git拉取代码后经常出现maven窗口不见
    SpringBoot入门教程之打成war包在tomcat容器中执行
  • 原文地址:https://www.cnblogs.com/aliceQin/p/9973732.html
Copyright © 2020-2023  润新知