Search code examples
javalogback

DBAppender - how to change default table names?


Is it possible to change the default table names for DBAppender in Logback and how can I do it ?

P.S. Browsing the sources I found that DBAppender uses the DBNameResolver interface for getting table names, I can implement this interface in a custom-made dbNameResolver and then use custom-made table names, but the major problem for me is how to set that custom-made dbNameResolver into my DBAppender... is that possible ?


Solution

  • From the API docs, it appears that DBAppender has a setDbNameResolver() property which could be invoked programatically, or, if I've understood how the configuration file works properly, just using something like:

    <appender name="DB" class="ch.qos.logback.classic.db.DBAppender">
       <.../>
       <dbNameResolver class="fqdn.to.my.DBNameResolver"/>
    </appender>