zoukankan      html  css  js  c++  java
  • 在springboot访问日志

    1.废话不多说,直接上工程结构。

    2.启动类随便加一个方法。

    @GetMapping("/hello")
        public String hello() {
            return "hello";
        }

    3.主要是yml文件的配置参数。

    server:
      tomcat:
        basedir: my-tomcat
        accesslog:
          pattern: 'ip: %A, response code: %s, time: %t'
          enabled: true
          directory: crazyit-logs
          buffered: false

    注:basedir指的是我们定义的根目录,而directory指的是生成的log存放目录,我们可根据需要修改目录路径。

    4.pom文件。

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>org.crazyit.boot.c3</groupId>
        <artifactId>log-test</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        
        <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>2.0.1.RELEASE</version>
        </parent>
    
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-test</artifactId>
                <scope>test</scope>
            </dependency>
        </dependencies>
        
    </project>

    5.访问localhost:8080/hello后,刷新工程后,可在指定目录看到生成的log文件。

  • 相关阅读:
    cscope使用技巧
    GNU的strong symbol和weak symbol
    vim自定义插件放入pathogen管理
    kernel生成针对x86架构的tags和cscope数据库
    vim+cscope简易教程
    mac重装系统
    Mac升级bash到最新版本
    Mac中提升权限修改系统目录
    macbook中gcc替换为gnu gcc
    固定二进制位的整型变量
  • 原文地址:https://www.cnblogs.com/malun/p/13921652.html
Copyright © 2011-2022 走看看