Note that there are some explanatory texts on larger screens.

plurals
  1. POCan I prevent logback's DBAppender from logging specific properties?
    primarykey
    data
    text
    <p>Logback's DBAppender logs all properties in its context and MDC to the database. I would like to control which properties are logged, specifically filtering out certain values, but I can't find any options to do so. The documentation is terse:</p> <blockquote> <p>The logging_event_property is used to store the keys and values contained in the MDC or the Context</p> </blockquote> <p>Is it possible to exclude certain properties from being logged?</p> <p>Here is an example:</p> <p>Logback is configured with a <code>DBAppender</code> that loads its properties from <code>vct.properties</code>:</p> <pre><code>&lt;configuration&gt; &lt;property resource="vct.properties" /&gt; &lt;appender name="DB" class="ch.qos.logback.classic.db.DBAppender"&gt; &lt;connectionSource class="ch.qos.logback.core.db.DataSourceConnectionSource"&gt; &lt;dataSource class="com.mchange.v2.c3p0.ComboPooledDataSource"&gt; &lt;driverClass&gt;com.mysql.jdbc.Driver&lt;/driverClass&gt; &lt;jdbcUrl&gt;jdbc:mysql://${log.db.host}:${log.db.port}/${log.db.schema}&lt;/jdbcUrl&gt; &lt;user&gt;${log.db.username}&lt;/user&gt; &lt;password&gt;${log.db.password}&lt;/password&gt; &lt;/dataSource&gt; &lt;/connectionSource&gt; &lt;/appender&gt; &lt;root level="DEBUG"&gt; &lt;appender-ref ref="DB" /&gt; &lt;/root&gt; &lt;/configuration&gt; </code></pre> <p><code>vct.properties</code> has the connection settings:</p> <pre><code>log.db.host=localhost log.db.port=3306 log.db.schema=logs_development log.db.username=loguser log.db.password=logpass </code></pre> <p>When an event is logged, all of the connection settings are logged:</p> <pre><code>mysql&gt; select * from logging_event_property where event_id=1; +----------+---------------------+-------------------------------------------+ | event_id | mapped_key | mapped_value | +----------+---------------------+-------------------------------------------+ | 1 | log.db.host | localhost | | 1 | log.db.password | logpass | | 1 | log.db.port | 3306 | | 1 | log.db.schema | logs_development | | 1 | log.db.username | loguser | +----------+---------------------+-------------------------------------------+ </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload