[
http://jira.jboss.com/jira/browse/JBCOMMON-27?page=comments#action_12379094 ]
Martin Putz commented on JBCOMMON-27:
-------------------------------------
With the proposed changes of returning Filter.NEUTRAL, the next filter in the filter chain
is consulted. This is the intended behavior of the original request. But this also means
that in the end all logging messages end up in the filtered log as well, and this in turn
is then equal to a non-filtered log. The reason for this can be found in the last sentence
of the description of the Filter.NEUTRAL return value: "Thus, in the presence of no
filters, the default behaviour is to log all logging events."
To get just the log events of several applications in a single log file, it is therefore
necessary to end this chain by appending the DenyAllFilter after the last TCLFilter. In
the case of the appender definition shown above this would look like:
<appender name="CONSOLE"
class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p [%t] %c -
%m%n"/>
</layout>
<filter class="org.jboss.logging.filter.TCLFilter">
<param name="AcceptOnMatch" value="false"/>
<param name="DeployURL"
value="jboss-common-client.jarpoyan"/>
</filter>
<filter class="org.jboss.logging.filter.TCLFilter">
<param name="AcceptOnMatch" value="false"/>
<param name="DeployURL" value="dnsns.jarpoyan"/>
</filter>
<!-- end the filter chain here -->
<filter class="org.apache.log4j.varia.DenyAllFilter"/>
</appender>
This also applies no matter how many TCLFilters are added to the appended, IOW this would
also have to be inserted after a single TCLFilter definition.
Incorrect behaviour in TCLFilter
---------------------------------
Key: JBCOMMON-27
URL:
http://jira.jboss.com/jira/browse/JBCOMMON-27
Project: JBoss Common
Issue Type: Bug
Security Level: Public(Everyone can see)
Affects Versions: 1.0.0.GA
Reporter: Scott M Stark
Assigned To: Scott M Stark
Fix For: 1.2.1.GA, 1.0.5.GA, 2.2.1.GA
Just one TCLFilter can be added to an appender, decide method return either ACCEPT or
DENY.
Should return NEUTRAL is some case.
public int decide(LoggingEvent event)
{
int ok = Filter.DENY;
if( acceptOnMatch == true )
{
ok = Filter.DENY;
if( isMatchingTCL() ){
ok = Filter.ACCEPT;
}
}
else
{
ok = Filter.ACCEPT; // CHANGING THIS ROW TO ok = Filter.NEUTRAL; should do that you check
the other filters to.
if( isMatchingTCL() )
ok = Filter.DENY;
}
return ok;
}
Log4j.xml:
<appender name="CONSOLE"
class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p [%t] %c -
%m%n"/>
</layout>
<filter class="org.jboss.logging.filter.TCLFilter">
<param name="AcceptOnMatch" value="false"/>
<param name="DeployURL"
value="jboss-common-client.jarpoyan"/>
</filter>
<filter class="org.jboss.logging.filter.TCLFilter">
<param name="AcceptOnMatch" value="false"/>
<param name="DeployURL" value="dnsns.jarpoyan"/>
</filter>
</appender>
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira