Return-Path: X-Original-To: apmail-logging-log4j-dev-archive@www.apache.org Delivered-To: apmail-logging-log4j-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8A41211945 for ; Wed, 3 Sep 2014 16:43:57 +0000 (UTC) Received: (qmail 52347 invoked by uid 500); 3 Sep 2014 16:43:53 -0000 Delivered-To: apmail-logging-log4j-dev-archive@logging.apache.org Received: (qmail 52225 invoked by uid 500); 3 Sep 2014 16:43:53 -0000 Mailing-List: contact log4j-dev-help@logging.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Log4J Developers List" Reply-To: "Log4J Developers List" Delivered-To: mailing list log4j-dev@logging.apache.org Received: (qmail 52110 invoked by uid 99); 3 Sep 2014 16:43:53 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Sep 2014 16:43:53 +0000 Date: Wed, 3 Sep 2014 16:43:53 +0000 (UTC) From: "Ralph Goers (JIRA)" To: log4j-dev@logging.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (LOG4J2-808) RegexFilter does not work properly with RollingFileAppenders MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/LOG4J2-808?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14120068#comment-14120068 ] Ralph Goers commented on LOG4J2-808: ------------------------------------ The part you seem to be missing is that filtering on every event does: If event matches filter perform onMatch else perform onMismatch. They are really simple. When you say "NPE" present that means that that specific event contains "NPE" and it will perform onMatch (and ignore onMismatch). However, if the event does not contain "NPE" it will ignore onMatch and perform onMismatch. There is no concept of "NPE" present somehow meaning that because some event has or will contain "NPE" all events should perform onMatch only. In fact, there is no way to even know that some event in the future might contain "NPE". So in case 2, if the event contains "NPE" then perform onMatch="ACCEPT" (log event). If the event does not contain "NPE" then perform onMismatch="NEUTRAL" (no other filters event is logged). So for two records: 1. "This event contains NPE". 2. "This event contains nothing". Event 1 is logged because it contains NPE. Event 2 is logged because it does not contain NPE and onMismatch is NEUTRAL and there are no other filters. In case 3, if the event contains "XYZ" then perform onMatch="ACCEPT" (log event). If the event does not contain "XYZ" then perform onMismatch="NEUTRAL" (no other filters event is logged). > RegexFilter does not work properly with RollingFileAppenders > ------------------------------------------------------------- > > Key: LOG4J2-808 > URL: https://issues.apache.org/jira/browse/LOG4J2-808 > Project: Log4j 2 > Issue Type: Bug > Components: Filters > Affects Versions: 2.0-rc1 > Reporter: Pranav Pratap > Labels: newbie > Fix For: 2.0-rc1 > > Attachments: HelloWorld.java, MainApp.java, log4j2.xml > > > I am trying to use Regexfilter in RollingFileAppender. For 1st matching instance it retreived the logger, but after that I different patttern but nothing is logged in the file. Here is what I am using: > {code} > Main Class: > public class MainApp { > /** > * @param args > */ > public static void main(String[] args) { > // TODO Auto-generated method stub > final Logger logger = LogManager.getLogger(MainApp.class.getName()); > > ApplicationContext context = new ClassPathXmlApplicationContext("Beans.xml"); > > HelloWorld obj = (HelloWorld) context.getBean("helloWorld"); > logger.trace("NPF:Trace:Entering Log4j2 Example."); > logger.debug("NTL:debug Entering Log4j2 Example."); > obj.getMessage(); > Company comp = new Company(); > comp.setCompName("ANC"); > comp.setEstablish(1889); > > CompanyBusiness compBus = (CompanyBusiness)context.getBean("compBus"); > compBus.finaceBusiness(comp.getCompName(), comp.getEstablish()); > logger.trace("NTL: Trace: Exiting Log4j2 Example."); > } > } > {code} > log4j2.xml: > {code} > > > > > > > filePattern="C:\logTest\runtime\tla\els3-%d{yyyy-MM-dd}-%i.log" > > > > > > > > > > > > > > > > > {code} > When I ran for the first time, in my logfile I got logs having only "business" related line. Latter I changed the patter from .*business*. to "business", logging did not happen in file nor on the console. Also my application terminated without any kind of logging. > Then I tried to revert back the pattern to .*business*., thereafter no logging happened on the log file, but on the console all the log trace is printed. When I comment out the Regexfilter after trying for long time, my logs was printed in the log file. > I am not sure if this is a bug of Regexfilter works only for one time. Also if we do not pass any patter matching characters, the application stops without any log printing either on console or file. -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org For additional commands, e-mail: log4j-dev-help@logging.apache.org