问题描述
是否可以在logback中更改DBAppender的默认表名,我该怎么办?
is it possibly to change default table names for DBAppender in logback and how can I do it ?
P.S。浏览源我发现DBAppender有属性实现的DBNameResolver接口用于获取表名,我可以在自定义的dbNameResolver中实现此接口,然后使用自定义表名,但我的主要问题是如何将自定义生成的dbNameResolver设置为原始DBAppender ......可能吗?
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 ?
推荐答案
来自,DBAppender有一个setDbNameResolver()属性,可以以编程方式调用,或者,如果我已经理解配置文件如何正常工作只是使用某些东西喜欢:
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>
这篇关于DBAppender - 如何更改默认表名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!