Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 982303 - Unable to use Filter Expressions in filter-spec
Summary: Unable to use Filter Expressions in filter-spec
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: JBoss Enterprise Application Platform 6
Classification: JBoss
Component: Logging
Version: 6.1.1
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: ER4
: EAP 6.2.0
Assignee: Emmanuel Hugonnet (ehsavoie)
QA Contact: Nikoleta Ziakova
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-07-08 15:38 UTC by Petr Kremensky
Modified: 2013-12-15 16:22 UTC (History)
3 users (show)

Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-12-15 16:22:27 UTC
Type: Bug


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Red Hat Bugzilla 951168 None None None Never
Red Hat One Jira Issue Tracker WFLY-1791 Minor Closed Unable to use Filter Expressions in filter-spec 2018-07-06 16:48:58 UTC

Internal Links: 951168

Description Petr Kremensky 2013-07-08 15:38:40 UTC
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\")",
...

but: 
[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 21:59:21 UTC
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 07:49:18 UTC
https://github.com/jbossas/jboss-eap/pull/270

Comment 5 Petr Kremensky 2013-09-12 09:01:18 UTC
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 09:17:13 UTC
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 09:45:20 UTC
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 14:55:09 UTC
The received command has lost the first escaped quote

Comment 9 Emmanuel Hugonnet (ehsavoie) 2013-09-18 16:08:58 UTC
/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 08:29:46 UTC
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 15:27:02 UTC
Alexey Loubyansky <alex@jboss.org> made a comment on jira WFLY-1791

This has been merged.

Comment 16 Petr Kremensky 2013-12-05 09:46:45 UTC
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.