DBAppender - how to change default table names?

2019-05-07 00:09发布

问题:

is it possibly to change default table names for DBAppender in logback and how can I do it ?

P.S. Browsing sources I found that DBAppender have property implemented DBNameResolver interface for getting table names, I can implement this interface in 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 original DBAppender... is that possibly ?

回答1:

From the API docs, 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>


标签: java logback