[logback-user] Extending logback configuration
Rahul Narula
ranarula at gmail.com
Tue Oct 16 02:14:22 CEST 2018
Hi
I have a default logback config. similar to the one below
<appender name="JSON_CONSOLE_APPENDER"
class="ch.qos.logback.core.ConsoleAppender">
<encoder class="a.b.c.logging.CustomLogbackEncoder">
<providers>
<timestamp/>
<version/>
<loggerName/>
<threadName/>
<logLevel/>
<provider class="a.b.c.logging.LogMaskingProvider">
<rules>
<rule>
<name>cc</name>
<pattern>\d{13,18}</pattern>
</rule>
<rule>
<name>SSN</name>
<pattern>\s+\d{3}-?\d{3}-?\d{4}\s+</pattern>
</rule>
</rules>
<userRules>
<!-- Read custom user rules --->
</userRules>
</provider>
<stackTrace/>
</providers>
</encoder>
The above config is read and configured using the ImplicitAction without
any issue and binds to a POJO
public class Rules {
private final Set<Rule> rules = new LinkedHashSet<>();
public void addRule(Rule definition) {
rules.add(definition.createRule());
}
...
}
acts as a default configuration. This default configuration is not directly
available to the clients, so they can't directly make changes to it.
I am looking for ways to extend this default configuration where in the
different users can specify additional rules in <userRules>. This
configuration is provided in separate file outside of logback.xml in a file
called custom.xml something like
<userRules>
<rule>
<name>email</name>
<pattern>([a-zA-Z0-9_\-\.]+)@[a-zA-Z0-9_\-\.]+\.[a-zA-Z]{2,5}</pattern>
</rule>
<rule>
...
</userRules>
I am looking for help to implement this so as that the logback config is
configured with the set of default + custom rules
Any pointers around how to implement this will be helpful
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20181015/e11edda5/attachment.html>
More information about the logback-user
mailing list