This is a case where I would recommend the application be modified, if
possible, to use a Marker. Instead of using a RegEx filter as Matt shows, which
can be expensive if you have lots of logging, you could use the MarkerFilter.
To do this, everywhere you log “Creating shared instance of singleton bean” or
something else you would like to optionally suppress create a Marker and add it
as a filter:
public static final Marker VERBOSE = MarkerManager.getMarker(“VERBOSE”);
logger.debug(VERBOSE, “Creating shared instance of singleton bean {}”,
className);
<Logger name=“com.example.thing” level=“DEBUG”>
<MarkerFilter marker=“VERBOSE” onMatch=“DENy” onMismatch=“NEUTRAL”/>
</Logger>
The usage of the filter is exactly as Matt explained regardless of which filter
you use.
Ralph
> On Nov 24, 2017, at 10:27 AM, Matt Sicker <[email protected]> wrote:
>
> On 23 November 2017 at 06:37, Remko Popma <[email protected]> wrote:
>
>> If you use a RegexFilter (
>> https://logging.apache.org/log4j/2.x/manual/filters.html#RegexFilter)
>> would
>> that meet your requirements?
>>
>>> <logger name=" org.springframework.beans.factory.support.
>> DefaultListableBeanFactory"
>>> level="DEBUG"> <include string= "Creating shared instance of
>>> singleton bean" <AppenderRef ref="PROJECT" />
>>> </logger>
>>
>
> Example usage:
>
> <Logger name="com.example.thing" level="DEBUG">
> <RegexFilter regex="Creating shared instance of singleton bean"
> onMismatch="DENY"/>
> <AppenderRef ref="PROJECT"/>
> </Logger>
>
> You can set that filter at the global level (inside <Configuration/>),
> per-appender (inside the <FooAppender/> element), per-logger (as
> described), or even inside the <AppenderRef/> element which can be useful
> if your <Logger/> has multiple AppenderRefs. See more info here: <
> https://logging.apache.org/log4j/2.x/manual/configuration.html#Filters>
>
> --
> Matt Sicker <[email protected]>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]