In einem aktuellen Projekt verwende ich SLF4J mit Logback und möchte einige Logs in die Datenbank schreiben lassen. Dafür liefert Logback auch geeignete SQL Statements. Da ich aber in meinem Projekt mit Liquibase unterwegs bin wollte ich das gerne mit in die DB-Changelog mit aufnehmen. Das Ergebnis dazu möchte ich hier teilen:
Changeset
< changeSet id = "1" author = "fhabermann" runAlways = "true" > < validCheckSum >any</ validCheckSum > < preConditions onFail = "MARK_RAN" > < not > < tableExists tableName = "logging_event" /> </ not > </ preConditions > < createTable tableName = "logging_event" > < column name = "timestmp" type = "BIGINT" > < constraints nullable = "false" /> </ column > < column name = "formatted_message" type = "TEXT" > < constraints nullable = "false" /> </ column > < column name = "logger_name" type = "VARCHAR(255)" > < constraints nullable = "false" /> </ column > < column name = "level_string" type = "VARCHAR(255)" > < constraints nullable = "false" /> </ column > < column name = "thread_name" type = "VARCHAR(255)" > < constraints nullable = "true" /> </ column > < column name = "reference_flag" type = "SMALLINT" > < constraints nullable = "true" /> </ column > < column name = "arg0" type = "VARCHAR(255)" > < constraints nullable = "true" /> </ column > < column name = "arg1" type = "VARCHAR(255)" > < constraints nullable = "true" /> </ column > < column name = "arg2" type = "VARCHAR(255)" > < constraints nullable = "true" /> </ column > < column name = "arg3" type = "VARCHAR(255)" > < constraints nullable = "true" /> </ column > < column name = "caller_filename" type = "VARCHAR(255)" > < constraints nullable = "false" /> </ column > < column name = "caller_class" type = "VARCHAR(255)" > < constraints nullable = "false" /> </ column > < column name = "caller_method" type = "VARCHAR(255)" > < constraints nullable = "false" /> </ column > < column name = "caller_line" type = "VARCHAR(4)" > < constraints nullable = "false" /> </ column > < column name = "event_id" type = "BIGINT" autoIncrement = "true" > < constraints nullable = "false" primaryKey = "true" /> </ column > </ createTable > </ changeSet > < changeSet id = "2" author = "fhabermann" runAlways = "true" > < validCheckSum >any</ validCheckSum > < preConditions onFail = "MARK_RAN" > < not > < tableExists tableName = "logging_event_exception" /> </ not > </ preConditions > < createTable tableName = "logging_event_exception" > < column name = "event_id" type = "BIGINT" >< constraints nullable = "false" /></ column > < column name = "i" type = "SMALLINT" >< constraints nullable = "false" /></ column > < column name = "trace_line" type = "VARCHAR(255)" >< constraints nullable = "false" /></ column > </ createTable > < addPrimaryKey tableName = "logging_event_exception" columnNames = "event_id,i" /> < addForeignKeyConstraint baseColumnNames = "event_id" baseTableName = "logging_event_exception" constraintName = "logging_event_exception_ibfk_1" onDelete = "CASCADE" onUpdate = "RESTRICT" referencedColumnNames = "event_id" referencedTableName = "logging_event" /> </ changeSet > < changeSet id = "3" author = "fhabermann" runAlways = "true" > < validCheckSum >any</ validCheckSum > < preConditions onFail = "MARK_RAN" > < not > < tableExists tableName = "logging_event_property" /> </ not > </ preConditions > < createTable tableName = "logging_event_property" > < column name = "event_id" type = "BIGINT" >< constraints nullable = "false" /></ column > < column name = "mapped_key" type = "VARCHAR(255)" >< constraints nullable = "false" /></ column > < column name = "mapped_value" type = "TEXT" >< constraints nullable = "true" /></ column > </ createTable > < addPrimaryKey tableName = "logging_event_property" columnNames = "event_id,mapped_key" /> < addForeignKeyConstraint baseColumnNames = "event_id" baseTableName = "logging_event_property" constraintName = "logging_event_property_ibfk_1" onDelete = "CASCADE" onUpdate = "RESTRICT" referencedColumnNames = "event_id" referencedTableName = "logging_event" /> </ changeSet > |