LordLamer
  • Home
  • About Me
  • Familie
  • Knowledgeroot
  • Impressum
KEEP IN TOUCH

SLF4J mit Logback und Liquibase

May12
2016
Written by lordlamer

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>
Posted in Java
SHARE THIS Twitter Facebook Delicious StumbleUpon E-mail
« Java XSL Transformation
» Neue Leselektüre ist da – The Book of PF

Community

  • Forum
  • GitHub
  • Knowledgeroot
  • YouTube

#lordlamer

Twitter Sent An Error: Could not authenticate you.

Categories

  • bsd (1)
  • citrix (3)
  • Company (24)
  • Debian (11)
  • Familie (75)
  • Geocaching (2)
  • Hausbau (41)
  • IPv6 (5)
  • Java (3)
  • klettern (10)
  • Knowledgeroot (15)
  • Linux (12)
  • LUG Balista (1)
  • misc (21)
  • mysql (1)
  • netscreen (2)
  • postgresql (1)
  • sap (4)
  • solr (2)
  • vim (2)

EvoLve theme by Theme4Press  •  Powered by WordPress LordLamer
Frank Habermann