Logback日志写入数据库

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

依赖


    ch.qos.logback
    logback-classic
    1.1.7


    ch.qos.logback
    logback-core
    1.1.7


    ch.qos.logback
    logback-access
    1.1.7


    org.slf4j
    slf4j-api
    1.7.21


    mysql
    mysql-connector-java
    5.1.38


    c3p0
    c3p0
    0.9.1.2

logback.xml


        
            
                com.mysql.jdbc.Driver
                jdbc:mysql://192.168.99.122:3306/cloud_meta_platform
                root
                root
                
            
        
        


        

建表

执行logback-classicjar包中的建表语句

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;

转载于:https://my.oschina.net/u/2356710/blog/895733

你可能感兴趣的:(Logback日志写入数据库)