SpringBoot整合Slf4j+logback日志框架--记录到数据库OK(3)

接着前面的第二篇

1、Maven增加依赖

SpringBoot整合Slf4j+logback日志框架--记录到数据库OK(3)_第1张图片 

        
        
            commons-dbcp
            commons-dbcp
            1.4
        

 2、修改logback.xml中的设定

SpringBoot整合Slf4j+logback日志框架--记录到数据库OK(3)_第2张图片 




    
    
    
     
    
        
            
            %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n
        
    

    
    
        
            
            ${LOG_HOME}/TestWeb.log.%d{yyyy-MM-dd}.log
            
            30
        
        
            
            %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n
        
        
        
            10MB
        
    
    
    
        
            com.mysql.cj.jdbc.Driver
            jdbc:mysql://127.0.0.1:3306/shujuku?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC
            root
            mima
        
    
    

    
    
    
        
        
        
    


 3、创建数据记录表

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),
    FOREIGN KEY (event_id) REFERENCES logging_event(event_id)
  );
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),
    FOREIGN KEY (event_id) REFERENCES logging_event(event_id)
  );
COMMIT;

 4、然后就看到记录了

 SpringBoot整合Slf4j+logback日志框架--记录到数据库OK(3)_第3张图片

你可能感兴趣的:(spring,boot)