@@ -98,6 +98,11 @@ Otherwise, a
9898link:../javadoc/log4j-core/org/apache/logging/log4j/core/LogEvent.html[`LogEvent`] is created and processing continues.
9999ACCEPT:: A `LogEvent` is created and processing continues in the next stage.
100100
101+ [IMPORTANT]
102+ ====
103+ This is the only stage, which differentiates between an `ACCEPT` and `NEUTRAL` filter result.
104+ ====
105+
101106[TIP]
102107====
103108Filtering logging calls at this stage provides the best performance:
@@ -188,7 +193,7 @@ of the appender reference.
188193* the xref:manual/configuration.adoc#appenderrefs-elements-filters[appender reference filter] must return `ACCEPT` or `NEUTRAL`,
189194
190195[#appender-stage]
191- === 4. `Appender` stage
196+ === 4. `Appender` stage (optional)
192197
193198[plantuml]
194199....
@@ -210,10 +215,15 @@ end group
210215@enduml
211216....
212217
213- When log events reach an appender,
218+ If the appender implements
219+ link:../javadoc/log4j-core/org/apache/logging/log4j/core/filter/Filterable.html[`Filterable`]
220+ an additional filtering stage is available.
221+ When log events reach such an appender,
214222the filter attached to an appender is evaluated and if the result is `DENY`,
215223the log event is discarded.
216224
225+ All standard appenders implement `Filterable`.
226+
217227[NOTE]
218228====
219229Some appenders like the
@@ -231,7 +241,7 @@ Using the `level` property of appender references will give a better performance
231241
232242[WARNING]
233243====
234- Configuring filters is a measure of last resort,
244+ Configuring filters at this stage is a measure of last resort,
235245since it adds a large overhead to disabled log events.
236246You should rather configure the filtering in one of the previous stages.
237247====
@@ -273,7 +283,7 @@ include::example$manual/filters/filters.properties[lines=17..-1]
273283====
274284
275285<1> Global filter
276- <2> Logger `level` attribute (it is skipped if the event matches the global filter)
286+ <2> Logger `level` attribute. This setting is **ignored** unless the global filter returns `NEUTRAL`.
277287<3> Filter of the `org.example` logger
278288<4> Filter of the root logger (it is the parent of the `org.example` logger)
279289<5> Appender reference `level` attribute
@@ -378,7 +388,7 @@ Timestamp filters use the timestamp of log events to decide whether to accept th
378388The `BurstFilter` limits the rate of log events.
379389The rate limit is only applied to log events less severe than a configured log level.
380390
381- Besides the common configuration attributes,
391+ Besides the << common-configuration-attributes,common configuration attributes>> ,
382392the `BurstFilter` supports the following parameters:
383393
384394.`BurstFilter` -- configuration attributes
@@ -425,7 +435,7 @@ xref:plugin-reference.adoc#org-apache-logging-log4j_log4j-core_org-apache-loggin
425435
426436The `TimeFilter` only matches log events emitted during a certain time of the day.
427437
428- Besides the common configuration attributes,
438+ Besides the << common-configuration-attributes,common configuration attributes>> ,
429439the `TimeFilter` supports the following parameters:
430440
431441.`TimeFilter` -- configuration attributes
@@ -501,7 +511,8 @@ The following filters allow you to filter log events based on their xref:manual/
501511
502512The `LevelMatchFilter` matches log events that have exactly a certain log level.
503513
504- Besides the common configuration attributes, the `LevelMatchFilter` supports the following parameter:
514+ Besides the <<common-configuration-attributes,common configuration attributes>>,
515+ the `LevelMatchFilter` supports the following parameter:
505516
506517.`LevelMatchFilter` -- configuration attributes
507518[cols="1m,1,1,4"]
@@ -517,9 +528,13 @@ Besides the common configuration attributes, the `LevelMatchFilter` supports the
517528
518529[TIP]
519530====
520- If you wish to use a different log file for each log level, you can also use a
531+ If you wish to use a different log file for each log level, you should also use a
521532xref:manual/appenders.adoc#RoutingAppender[`Routing` appender] together with the
522533xref:manual/lookups.adoc#EventLookup[`${event:Level}` lookup].
534+ Such a solution will ensure that:
535+
536+ * you don't forget any log level (Log4j supports xref:manual/customloglevels.adoc[custom levels]).
537+ * you don't need to configure an appender for each level separately.
523538====
524539
525540xref:plugin-reference.adoc#org-apache-logging-log4j_log4j-core_org-apache-logging-log4j-core-filter-LevelMatchFilter[📖 Plugin reference for `LevelMatchFilter`]
@@ -529,7 +544,8 @@ xref:plugin-reference.adoc#org-apache-logging-log4j_log4j-core_org-apache-loggin
529544
530545The `LevelRangeFilter` matches log events with a log level within a configured range.
531546
532- Besides the common configuration attributes, the `LevelRangeFilter` supports the following parameter:
547+ Besides the <<common-configuration-attributes,common configuration attributes>>,
548+ the `LevelRangeFilter` supports the following parameter:
533549
534550.`LevelRangeFilter` -- configuration attributes
535551[cols="1m,1,1,4"]
@@ -561,7 +577,8 @@ xref:plugin-reference.adoc#org-apache-logging-log4j_log4j-core_org-apache-loggin
561577
562578The `ThresholdFilter` matches log events at least as severe as a configured level.
563579
564- Besides the common configuration attributes, the `ThresholdFilter` supports the following parameter:
580+ Besides the <<common-configuration-attributes,common configuration attributes>>,
581+ the `ThresholdFilter` supports the following parameter:
565582
566583.`ThresholdFilter`—configuration attributes
567584[cols="1m,1,1,4"]
@@ -592,7 +609,8 @@ For each log event:
592609xref:plugin-reference.adoc#org-apache-logging-log4j_log4j-core_org-apache-logging-log4j-core-util-KeyValuePair[`KeyValuePair`]
593610configuration elements to decide which level to apply.
594611
595- Besides the common configuration attributes, the `DynamicThresholdFilter` supports the following parameters:
612+ Besides the <<common-configuration-attributes,common configuration attributes>>,
613+ the `DynamicThresholdFilter` supports the following parameters:
596614
597615.`DynamicThresholdFilter`—configuration attributes
598616[cols="1m,1,1,4"]
@@ -687,7 +705,8 @@ to filter log events.
687705
688706The `NoMarkerFilter` matches log events that do not have any markers.
689707
690- This filter does not have any additional configuration attribute, except the common attributes.
708+ This filter does not have any additional configuration attribute,
709+ except the <<common-configuration-attributes,common configuration attributes>>.
691710
692711xref:plugin-reference.adoc#org-apache-logging-log4j_log4j-core_org-apache-logging-log4j-core-filter-NoMarkerFilter[📖 Plugin reference for `NoMarkerFilter`]
693712
@@ -696,7 +715,8 @@ xref:plugin-reference.adoc#org-apache-logging-log4j_log4j-core_org-apache-loggin
696715
697716The `MarkerFilter` matches log events marked with a specific marker or **any** of its descendants.
698717
699- Besides the common configuration attributes, the `MarkerFilter` supports the following parameter:
718+ Besides the <<common-configuration-attributes,common configuration attributes>>,
719+ the `MarkerFilter` supports the following parameter:
700720
701721.`MarkerFilter`—configuration attributes
702722[cols="1m,1,1,4"]
732752link:../javadoc/log4j-api/org/apache/logging/log4j/message/Message.html#getFormat()[`Message.getFormattedMessage()`].
733753It can be used with all kinds of `Message` implementations.
734754
735- Besides the common configuration attributes, the `RegexFilter` supports the following parameters:
755+ Besides the <<common-configuration-attributes,common configuration attributes>>,
756+ the `RegexFilter` supports the following parameters:
736757
737758.`RegexFilter` -- configuration attributes
738759[cols="1m,1,1,4"]
@@ -758,9 +779,11 @@ is used.
758779
759780|===
760781
761- [NOTE ]
782+ [WARNING ]
762783====
763- This filter only matches if the **whole** log message matches the regular expression.
784+ * This filter only matches if the **whole** log message matches the regular expression.
785+
786+ * Setting `useRawMsg` to `false` decreases performance, since it forces the formatting of all log messages, including the disabled ones.
764787====
765788
766789xref:plugin-reference.adoc#org-apache-logging-log4j_log4j-core_org-apache-logging-log4j-core-filter-RegexFilter[📖 Plugin reference for `RegexFilter`]
@@ -770,7 +793,8 @@ xref:plugin-reference.adoc#org-apache-logging-log4j_log4j-core_org-apache-loggin
770793
771794The `StringMatchFilter` matches a log event, if its message contains the given string.
772795
773- Besides the common configuration attributes, the `StringMatchFilter` supports the following parameters:
796+ Besides the <<common-configuration-attributes,common configuration attributes>>,
797+ the `StringMatchFilter` supports the following parameters:
774798
775799.`StringMatchFilter`—configuration attributes
776800[cols="1m,1,1,4"]
@@ -786,6 +810,11 @@ Besides the common configuration attributes, the `StringMatchFilter` supports th
786810
787811|===
788812
813+ [WARNING]
814+ ====
815+ This filter decreases performance, since it forces the formatting of all log messages, including the disabled ones.
816+ ====
817+
789818xref:plugin-reference.adoc#org-apache-logging-log4j_log4j-core_org-apache-logging-log4j-core-filter-StringMatchFilter[📖 Plugin reference for `StringMatchFilter`]
790819
791820[#map-filters]
@@ -853,7 +882,8 @@ xref:manual/messages.adoc#collection-structured[structured ``Message``s].
853882This filter encodes the <<configuration-map>> introduced above as a list of
854883`KeyValuePair` elements.
855884
856- Besides the common configuration attributes, the `MapFilter` supports the following parameters:
885+ Besides the <<common-configuration-attributes,common configuration attributes>>,
886+ the `MapFilter` supports the following parameters:
857887
858888.`MapFilter` -- configuration attributes
859889[cols="1m,1,1,4"]
@@ -973,7 +1003,8 @@ link:../javadoc/log4j-api/org/apache/logging/log4j/message/Message.html#getForma
9731003|===
9741004
9751005The `StructuredDataFilter` encodes the <<configuration-map>> introduced above as a list of
976- `KeyValuePair` and supports the following parameters, besides the common configuration attributes:
1006+ `KeyValuePair` and supports the following parameters,
1007+ besides the <<common-configuration-attributes,common configuration attributes>>:
9771008
9781009.`StructuredDataFilter`—configuration attributes
9791010[cols="1m,1,1,4"]
@@ -1062,7 +1093,8 @@ of the log event instead of the log message.
10621093This filter also encodes the <<configuration-map>> introduced above as a list of
10631094`KeyValuePair` elements.
10641095
1065- Besides the common configuration attributes, the `ContextMapFilter` supports the following parameters:
1096+ Besides the <<common-configuration-attributes,common configuration attributes>>,
1097+ the `ContextMapFilter` supports the following parameters:
10661098
10671099.`ContextMapFilter` -- configuration attributes
10681100[cols="1m,1,1,4"]
@@ -1150,7 +1182,8 @@ to filter messages, but externalizes the <<configuration-map>>, so it can be kep
11501182This filter encodes the <<configuration-map>> as JSON.
11511183The configuration map must be stored in an **external** location and will be regularly polled for changes.
11521184
1153- Besides the common configuration attributes, the `MutableContextMapFilter` supports the following parameters:
1185+ Besides the <<common-configuration-attributes,common configuration attributes>>,
1186+ the `MutableContextMapFilter` supports the following parameters:
11541187
11551188.`MutableContextMapFilter` -- configuration attributes
11561189[cols="1m,1,1,4"]
@@ -1249,7 +1282,8 @@ xref:plugin-reference.adoc#org-apache-logging-log4j_log4j-core_org-apache-loggin
12491282
12501283The `ScriptFilter` executes a script that must return `true` if the event matches and `false` otherwise.
12511284
1252- Besides the common configuration attributes, it accepts a single nested element:
1285+ Besides the <<common-configuration-attributes,common configuration attributes>>,
1286+ it accepts a single nested element:
12531287
12541288.`ScriptFilter` -- nested elements
12551289[cols="3,1,4"]
0 commit comments