Bug 982303 - Unable to use Filter Expressions in filter-spec
Unable to use Filter Expressions in filter-spec
Product: JBoss Enterprise Application Platform 6
Classification: JBoss
Component: Logging (Show other bugs)
Unspecified Unspecified
unspecified Severity high
: ER4
: EAP 6.2.0
Assigned To: Emmanuel Hugonnet (ehsavoie)
Nikoleta Ziakova
Depends On:
  Show dependency treegraph
Reported: 2013-07-08 11:38 EDT by Petr Kremensky
Modified: 2013-12-15 11:22 EST (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2013-12-15 11:22:27 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

External Trackers
Tracker ID Priority Status Summary Last Updated
JBoss Issue Tracker WFLY-1791 Minor Closed Unable to use Filter Expressions in filter-spec 2018-07-06 12:48 EDT

  None (edit)
Description Petr Kremensky 2013-07-08 11:38:40 EDT
Description of problem:
I am really not sure how to create logging filters using filter-spec.

I am able to use only: accept, deny, not and match expressions.

I tried to use deprecated filter attribute for help:
[standalone@localhost:9999 console-handler=CONSOLE] :write-attribute(name=filter, value={replace => {"pattern" => "JBAS","replacement" => "DUMMY","replace-all" => true}})

will create:
[standalone@localhost:9999 console-handler=CONSOLE] :read-resource
"filter-spec" => "substituteAll(\"JBAS\",\"DUMMY\")",

[standalone@localhost:9999 console-handler=CONSOLE] :write-attribute(name=filter-spec, value=substituteAll("JBAS","DUMMY"))
    "outcome" => "failed",
    "failure-description" => "JBAS014688: Wrong type for filter-spec. Expected [EXPRESSION, STRING] but was LIST",
    "rolled-back" => true

Did I overlook something? If yes, can you please create some simple example commands, so we can add this feature to EAP documentation.

I use community documentation here https://docs.jboss.org/author/display/AS72/Logging+Configuration#LoggingConfiguration-FilterExpressions

Version-Release number of selected component (if applicable):
EAP 6.1.1 ER2
Comment 1 James Perkins 2013-07-12 17:59:21 EDT
It's more likely an issue with the way CLI parses the value. Your value argument is correct. I'm not sure if it's possible to use in CLI which is a problem. I can't figure out the syntax at least. It tried escaping with " with \", but that didn't work.
Comment 4 Emmanuel Hugonnet (ehsavoie) 2013-08-01 03:49:18 EDT
Comment 5 Petr Kremensky 2013-09-12 05:01:18 EDT
I am quite confused by this fix. You've just added test for filter (which is deprecated, filter-spec should be used instead). Filter expressions are still not working.
You can try examples from documentation - (13.1.5. Filter Expressions for Logging)
 - http://documentation-devel.engineering.redhat.com/docs/en-US/Red_Hat_JBoss_Enterprise_Application_Platform/6.1/html/Administration_and_Configuration_Guide/chap-The_Logging_Subsystem.html#Filter_Expressions_for_Logging
Comment 6 Emmanuel Hugonnet (ehsavoie) 2013-09-12 05:17:13 EDT
I thought you had an issue creating the filters through the cli which this test checks.
Could you be more precise on what you mean by 'not working' ?
Comment 7 Petr Kremensky 2013-09-12 05:45:20 EDT
I had an issue with creating filter-spec through the cli.

There are two attributes in every logging handler, filter and filter-spec.
Filter accepts type OBJECT, but it is deprecated now and filter-spec should be used as alternative.

see CLI read-resource output:
"filter" => {   "type" => OBJECT,
                "description" => "Defines a simple filter type.",
                "alternatives" => ["filter-spec"],
                "deprecated" => {
                    "since" => "1.2.0",
                    "reason" => "Use filter-spec."

Filter-spec accepts Strings and should be able to cover functionality of original filter.

My problem is, that I am unable to create more complicated filters with filter-spec eg. :write-attribute(name=filter-spec, value=substituteAll("JBAS","DUMMY")).
Comment 8 Emmanuel Hugonnet (ehsavoie) 2013-09-13 10:55:09 EDT
The received command has lost the first escaped quote
Comment 9 Emmanuel Hugonnet (ehsavoie) 2013-09-18 12:08:58 EDT
/subsystem=logging/console-handler=CONSOLE:write-attribute(name=filter-spec, value=substituteAll("JBAS" \, "DUMMY")) is working

You have to escape the comma so the value is correctly assumed to be a String otherwise it would be parsed as a List.
Comment 10 JBoss JIRA Server 2013-09-27 04:29:46 EDT
Emmanuel Hugonnet <ehugonne@redhat.com> made a comment on jira WFLY-1791

The argument values are parsed a second time which means that the escaped char have been unescaped.
Changing this in the PR: https://github.com/wildfly/wildfly/pull/5159
Comment 12 JBoss JIRA Server 2013-10-02 11:27:02 EDT
Alexey Loubyansky <alex@jboss.org> made a comment on jira WFLY-1791

This has been merged.
Comment 16 Petr Kremensky 2013-12-05 04:46:45 EST
Verified on EAP 6.2.0.CR3.

One can use filter expression with escaped comma like:
[standalone@localhost:9999 /] /subsystem=logging/console-handler=CONSOLE:write-attribute(name=filter-spec, value=substituteAll("JBAS"\,"SABJ"))

Note You need to log in before you can comment on or make changes to this bug.