You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Andi Büchler (Jira)" <ji...@apache.org> on 2021/07/30 14:21:00 UTC

[jira] [Updated] (LOG4J2-3132) Adding BurstFilter with Java configuration

     [ https://issues.apache.org/jira/browse/LOG4J2-3132?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andi Büchler updated LOG4J2-3132:
---------------------------------
    Description: 
I'm trying to figure out how to apply a BurstFilter to an Appender and limit the number of messages to 1 per / second and maxBurst to 1 via Java configuration but somehow the filter isn't applied and I get an error:

 
{noformat}
ERROR appender RollbarAppender has no parameter that matches element BurstFilter{noformat}
So what's the correct way to add filters? This is what I've got:
{code:java}
	@Bean
	public AppenderComponentBuilder rollbarAppender() {
		return configurationBuilder.newAppender("RollbarAppender", RollbarAppender.ROLLBAR_APPENDER_PLUGIN_NAME)
			..
			.add(configurationBuilder.newFilter("BurstFilter", Filter.Result.NEUTRAL, Filter.Result.DENY)
				.addAttribute("level", Level.ERROR) 
				.addAttribute("rate", "0.016")
				.addAttribute("maxBurst", "1"));
	}
{code}

  was:
I'm trying to figure out how to apply a BurstFilter to an Appender and limit the number of messages to 1 per / second and maxBurst to 1 via Java configuration but somehow the filter isn't applied and I get an error:

 
{noformat}
ERROR appender RollbarAppender has no parameter that matches element BurstFilter{noformat}
So what's the correct way to add filters? This is what I've got:

 
{code:java}
	@Bean
	public AppenderComponentBuilder rollbarAppender() {
		return configurationBuilder.newAppender("RollbarAppender", RollbarAppender.ROLLBAR_APPENDER_PLUGIN_NAME)
			..
			.add(configurationBuilder.newFilter("BurstFilter", Filter.Result.NEUTRAL, Filter.Result.DENY)
				.addAttribute("level", Level.ERROR) // Level of messages to be filtered. Anything at or below this level will be filtered out if maxBurst has been exceeded.
				.addAttribute("rate", "0.016") // The average number of events per second to allow.
				.addAttribute("maxBurst", "1")); // The maximum number of events that can occur before events are filtered for exceeding the average rate. The default is 10 times the rate.
	}
{code}


> Adding BurstFilter with Java configuration
> ------------------------------------------
>
>                 Key: LOG4J2-3132
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-3132
>             Project: Log4j 2
>          Issue Type: Question
>          Components: Filters
>    Affects Versions: 2.14.1
>            Reporter: Andi Büchler
>            Priority: Major
>
> I'm trying to figure out how to apply a BurstFilter to an Appender and limit the number of messages to 1 per / second and maxBurst to 1 via Java configuration but somehow the filter isn't applied and I get an error:
>  
> {noformat}
> ERROR appender RollbarAppender has no parameter that matches element BurstFilter{noformat}
> So what's the correct way to add filters? This is what I've got:
> {code:java}
> 	@Bean
> 	public AppenderComponentBuilder rollbarAppender() {
> 		return configurationBuilder.newAppender("RollbarAppender", RollbarAppender.ROLLBAR_APPENDER_PLUGIN_NAME)
> 			..
> 			.add(configurationBuilder.newFilter("BurstFilter", Filter.Result.NEUTRAL, Filter.Result.DENY)
> 				.addAttribute("level", Level.ERROR) 
> 				.addAttribute("rate", "0.016")
> 				.addAttribute("maxBurst", "1"));
> 	}
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)