I would expect the Properties issue would affect all the implementations.

The enhancement you suggest would make the properties configuration different 
than 
the other configuration formats as they all require the Filters element. This 
is yet another 
example of why most (or all) of the log4j 2 developers really do not like the 
properties 
format and wonder why so many people prefer it.

FWIW, I am not against making the proposed change. We already do other stuff to 
make 
the properties configuration more usable.

Ralph

> On Apr 2, 2022, at 11:08 PM, Piotr P. Karwasz <piotr.karw...@gmail.com> wrote:
> 
> Hello Stamatis,
> 
> I posted a working solution on SO:
> 
> logger.t1.filter.M.type = Filters
> logger.t1.filter.M.f1.type = RegexFilter
> logger.t1.filter.M.f1.regex = .*SQL.*
> logger.t1.filter.M.f1.onMatch = NEUTRAL
> logger.t1.filter.M.f1.onMismatch = DENY
> logger.t1.filter.M.f2.type = RegexFilter
> logger.t1.filter.M.f2.regex = .*JPQL.*
> logger.t1.filter.M.f2.onMatch = NEUTRAL
> logger.t1.filter.M.f2.onMismatch = DENY
> 
> The problem is caused by two facts:
> 1. The `LoggerConfig` only accepts a single filter, so you have to
> wrap them in a "Filters" element,
> 2. A `Properties` class is a `Hashtable`, so the order of the keys is random.
> 
> I believe both of them to be bugs of `PropertiesConfigurationBuilder`:
> 1. I interpret the "filter" prefix in the properties configuration as
> an implicit "Filters" component. `addFiltersToComponent` should wrap
> the filters in a "Filters" component if more than one is defined.
> 2. `PropertiesUtil#partitionOnCommonPrefixes` should probably return a
> `TreeMap` instead of a `HashMap` to impose a deterministic order on
> the filters (and other components that use this function).
> 
> You should open a JIRA ticket for this problem and since you
> apparently have a PR in progress, submit your test case and a solution
> as PR.
> 
> Best wishes,
> Piotr
> 
> On Sat, 2 Apr 2022 at 18:44, Stamatis Zampetakis <zabe...@gmail.com> wrote:
>> 
>> Hi all,
>> 
>> After many unsuccessful attempts to configure a composite filter for a
>> specified logger [1] using the property syntax, I posted the following
>> question on stackoverflow [2].
>> 
>> In [1], I tried to create a unit test simulating what I would like to
>> achieve but didn't manage to make it work yet. I searched in the code to
>> find examples of how this can be done but couldn't find any.
>> 
>> Any feedback would be much appreciated!
>> 
>> Best,
>> Stamatis
>> 
>> [1]
>> https://github.com/zabetak/logging-log4j2/commit/a9944885100db42f7e3ba1b3ff81d59b743d0ab7
>> [2]
>> https://stackoverflow.com/questions/71719354/configure-composite-filter-for-specific-logger-in-log4j2-via-properties-file
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> For additional commands, e-mail: log4j-user-h...@logging.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org

Reply via email to