@@ -191,8 +191,114 @@ admin@example:/>
191191```
192192
193193See the above [ Log to File] ( #log-to-file ) section on how to set up
194- filtering of received logs to local files. Please note, filtering based
195- on property, e.g., hostname, is not supported yet.
194+ filtering of received logs to local files. Advanced filtering based
195+ on hostname and message properties is also available, see the next
196+ section for details.
197+
198+ ## Advanced Filtering
199+
200+ The syslog subsystem supports several advanced filtering options that
201+ allow fine-grained control over which messages are logged. These can
202+ be combined with facility and severity filters to create sophisticated
203+ logging rules.
204+
205+ ### Pattern Matching
206+
207+ Messages can be filtered using regular expressions (POSIX extended regex)
208+ on the message content. This is useful when you want to log only messages
209+ containing specific keywords or patterns:
210+
211+ ```
212+ admin@example:/config/> edit syslog actions log-file file:errors
213+ admin@example:/config/syslog/…/file:errors/> set pattern-match "ERROR|CRITICAL|FATAL"
214+ admin@example:/config/syslog/…/file:errors/> set facility-list all severity info
215+ admin@example:/config/syslog/…/file:errors/> leave
216+ admin@example:/>
217+ ```
218+
219+ This will log all messages containing ERROR, CRITICAL, or FATAL.
220+
221+ ### Advanced Severity Comparison
222+
223+ By default, severity filtering uses "equals-or-higher" comparison,
224+ meaning a severity of ` error ` will match error, critical, alert, and
225+ emergency messages. You can change this behavior:
226+
227+ ```
228+ admin@example:/config/> edit syslog actions log-file file:daemon-errors
229+ admin@example:/config/syslog/…/file:daemon-errors/> set facility-list daemon
230+ admin@example:/config/syslog/…/daemon/> set severity error
231+ admin@example:/config/syslog/…/daemon/> set advanced-compare compare equals
232+ admin@example:/config/syslog/…/daemon/> leave
233+ admin@example:/>
234+ ```
235+
236+ This will log only ` error ` severity messages, not higher severities.
237+
238+ You can also block specific severities:
239+
240+ ```
241+ admin@example:/config/syslog/…/daemon/> set advanced-compare action block
242+ ```
243+
244+ This will exclude ` error ` messages from the log.
245+
246+ ### Hostname Filtering
247+
248+ When acting as a log server, you can filter messages by hostname. This
249+ is useful for directing logs from different devices to separate files:
250+
251+ ```
252+ admin@example:/config/> edit syslog actions log-file file:router1
253+ admin@example:/config/syslog/…/file:router1/> set hostname-filter router1
254+ admin@example:/config/syslog/…/file:router1/> set facility-list all severity info
255+ admin@example:/config/syslog/…/file:router1/> leave
256+ admin@example:/>
257+ ```
258+
259+ Multiple hostnames can be added to the filter list.
260+
261+ ### Property-Based Filtering
262+
263+ For more advanced filtering, you can match on specific message properties
264+ using various comparison operators:
265+
266+ ```
267+ admin@example:/config/> edit syslog actions log-file file:myapp
268+ admin@example:/config/syslog/…/file:myapp/> edit property-filter
269+ admin@example:/config/syslog/…/property-filter/> set property programname
270+ admin@example:/config/syslog/…/property-filter/> set operator isequal
271+ admin@example:/config/syslog/…/property-filter/> set value myapp
272+ admin@example:/config/syslog/…/property-filter/> leave
273+ admin@example:/>
274+ ```
275+
276+ Available properties:
277+ - ` msg ` : Message body
278+ - ` msgid ` : RFC5424 message identifier
279+ - ` programname ` : Program/tag name
280+ - ` hostname ` : Source hostname
281+ - ` source ` : Alias for hostname
282+ - ` data ` : RFC5424 structured data
283+
284+ Available operators:
285+ - ` contains ` : Substring match
286+ - ` isequal ` : Exact equality
287+ - ` startswith ` : Prefix match
288+ - ` regex ` : Basic regular expression
289+ - ` ereregex ` : Extended regular expression (POSIX ERE)
290+
291+ The comparison can be made case-insensitive:
292+
293+ ```
294+ admin@example:/config/syslog/…/property-filter/> set case-insensitive true
295+ ```
296+
297+ Or negated to exclude matching messages:
298+
299+ ```
300+ admin@example:/config/syslog/…/property-filter/> set negate true
301+ ```
196302
197303### Facilities
198304
0 commit comments