• Spring Boot—16日志设置


    application.properties

    #
    server.address=0.0.0.0
    server.port=8080
    server.servlet.context-path=/test
    server.session.timeout=300
    server.error.path=/error
    #
    server.tomcat.accesslog.enabled=true
    server.tomcat.accesslog.buffered=true
    server.tomcat.accesslog.directory=D:/Project/JavaWeb/SpringBoot/04JPASpringBoot/logs
    #
    spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
    spring.jackson.time-zone=Asia/Shanghai
    #
    spring.thymeleaf.cache=true
    spring.thymeleaf.enabled=true
    
    file.upload.path=D:/Project/JavaWeb/SpringBoot/04JPASpringBoot/fileUpLoad
    
    spring.servlet.multipart.enabled=true
    spring.servlet.multipart.file-size-threshold=0
    spring.servlet.multipart.location=D:/Project/JavaWeb/SpringBoot/04JPASpringBoot/temp
    spring.servlet.multipart.max-file-size=10MB
    spring.servlet.multipart.max-request-size=10MB
    spring.servlet.multipart.resolve-lazily=false
    
    
    spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
    spring.datasource.druid.one.url=jdbc:mysql://127.0.0.1:3306/test?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false
    spring.datasource.druid.one.username=root
    spring.datasource.druid.one.password=gis
    spring.datasource.druid.one.driver-class-name=com.mysql.cj.jdbc.Driver
    
    ##Druid
    spring.datasource.druid.one.initial-size=2
    spring.datasource.druid.one.max-active=5
    spring.datasource.druid.one.min-idle=1
    spring.datasource.druid.one.max-wait=60000
    spring.datasource.druid.one.pool-prepared-statements=true
    spring.datasource.druid.one.max-pool-prepared-statement-per-connection-size=20
    spring.datasource.druid.one.validation-query=SELECT 1 FROM DUAL
    spring.datasource.druid.one.validation-query-timeout=60000
    spring.datasource.druid.one.test-on-borrow=false
    spring.datasource.druid.one.test-on-return=false
    spring.datasource.druid.one.test-while-idle=true
    spring.datasource.druid.one.time-between-eviction-runs-millis=60000
    spring.datasource.druid.one.min-evictable-idle-time-millis=100000
    #spring.datasource.druid.one.max-evictable-idle-time-millis=
    spring.datasource.druid.one.filters=stat,wall,log
    spring.datasource.druid.one.logSlowSql=true
    
    #
    # debug=true # Enable debug logs.
    # trace=true # Enable trace logs.
    
    # LOGGING
    logging.config=classpath:logback.xml

    logback.xml

    <?xml version="1.0" encoding="utf-8"?>
    
    <configuration debug="false"> 
      <property name="LOG_HOME" value="D:/Project/JavaWeb/SpringBoot/04JPASpringBoot/logs"/>  
      <timestamp key="bySecond" datePattern="yyyyMMddHHmmss"/>  
      <!-- 控制台输出 -->  
      <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> 
        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> 
          <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 -->  
          <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} -%msg%n</pattern> 
        </encoder> 
      </appender>  
      <!--myibatis log configure -->  
      <logger name="com.apache.ibatis" level="TRACE"/>  
      <logger name="java.sql.Connection" level="DEBUG"/>  
      <logger name="java.sql.Statement" level="DEBUG"/>  
      <logger name="java.sql.PreparedStatement" level="DEBUG"/>  
      <!-- 按照每天生成日志文件 -->  
      <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> 
        <file>${LOG_HOME}/log-${bySecond}.log</file>  
        <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> 
          <fileNamePattern>${LOG_HOME}/test.%i.log.zip</fileNamePattern>  
          <minIndex>1</minIndex>  
          <maxIndex>3</maxIndex> 
        </rollingPolicy>  
        <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> 
          <maxFileSize>5MB</maxFileSize> 
        </triggeringPolicy>  
        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> 
          <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 -->  
          <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} -%msg%n</pattern> 
        </encoder>  
        <!--日志文件最大的大小 -->  
        <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> 
          <MaxFileSize>2MB</MaxFileSize> 
        </triggeringPolicy> 
      </appender>  
      <!--日志异步到数据库 -->  
      <appender name="DB" class="ch.qos.logback.classic.db.DBAppender"> 
        <connectionSource class="ch.qos.logback.core.db.DriverManagerConnectionSource"> 
          <driverClass>com.mysql.cj.jdbc.Driver</driverClass>  
          <url>jdbc:mysql://127.0.0.1:3306/test?serverTimezone=Asia/Shanghai&amp;useUnicode=true&amp;characterEncoding=utf8&amp;useSSL=false</url>  
          <user>root</user>  
          <password>gis</password> 
        </connectionSource> 
      </appender>  
      <!-- 日志输出级别 -->  
      <root level="INFO"> 
        <appender-ref ref="STDOUT"/>  
        <appender-ref ref="FILE"/>  
        <appender-ref ref="DB"/> 
      </root> 
    </configuration>
     
    创建数据库的SQL脚本
     
    BEGIN;    
    DROP TABLE IF EXISTS logging_event_property;    
    DROP TABLE IF EXISTS logging_event_exception;    
    DROP TABLE IF EXISTS logging_event;    
    COMMIT;    
        
    BEGIN;    
    CREATE TABLE logging_event     
      (    
        timestmp         BIGINT NOT NULL,    
        formatted_message  TEXT NOT NULL,    
        logger_name       VARCHAR(254) NOT NULL,    
        level_string      VARCHAR(254) NOT NULL,    
        thread_name       VARCHAR(254),    
        reference_flag    SMALLINT,    
        arg0              VARCHAR(254),    
        arg1              VARCHAR(254),    
        arg2              VARCHAR(254),    
        arg3              VARCHAR(254),    
        caller_filename   VARCHAR(254) NOT NULL,    
        caller_class      VARCHAR(254) NOT NULL,    
        caller_method     VARCHAR(254) NOT NULL,    
        caller_line       CHAR(4) NOT NULL,    
        event_id          BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY    
      );    
    COMMIT;    
    BEGIN;    
    CREATE TABLE logging_event_property    
      (    
        event_id          BIGINT NOT NULL,    
        mapped_key        VARCHAR(254) NOT NULL,    
        mapped_value      TEXT,    
        PRIMARY KEY(event_id, mapped_key)    
      );    
    COMMIT;    
    BEGIN;    
    CREATE TABLE logging_event_exception    
      (    
        event_id         BIGINT NOT NULL,    
        i                SMALLINT NOT NULL,    
        trace_line       VARCHAR(254) NOT NULL,    
        PRIMARY KEY(event_id, i)    
      );    
    COMMIT;
     
     
    image
     
     
  • 相关阅读:
    家庭记账本安卓版开发:第一天
    家庭记账本安卓版开发:第二天
    通过Android的API对Sqlite数据库进行操作
    通过SQL语句操作Sqlite数据库
    Activity组件(四):通过requestCode和resultCode来实现Activity间的数据回传
    Activity组件(三):通过对象实现信息添加及展示
    家庭记账本安卓版开发:第三天
    梦断代码(三)
    MacType使用配置
    去掉win7快捷方式箭头及修复锁定到任务栏失效
  • 原文地址:https://www.cnblogs.com/gispathfinder/p/8946792.html
Copyright © 2020-2023  润新知