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

@phpmagazin Kann man einzelne Magazine auch online irgendwo einkaufen ohne das man gleich ein ABO abschließen muss? - 9 months ago

RT @DanShappir: Anything that can be done in HTML and CSS (without JavaScript) should be done in HTML and CSS (without JavaScript) - 10 months ago

@mauricerenck Bin auch kein Freund davon.... - 1 year ago

@jcagundlach @DB_Bahn Willkommen in Schwarzenbek ;) Dann hab ich dich gestern da stehen sehen... - 1 year ago

das nervt mich auch tierisch... zu viel Sicherheit das es schon fast unfreundlich ist es zu benutzen. Mach daraus m… https://t.co/VDTvD12q8c - 1 year ago

Visit My Profile

Categories

  • bsd (1)
  • citrix (3)
  • Company (24)
  • Debian (11)
  • Familie (88)
  • Geocaching (2)
  • Hausbau (41)
  • IPv6 (5)
  • Java (3)
  • klettern (23)
  • 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