Return-Path: Delivered-To: apmail-logging-log4j-user-archive@www.apache.org Received: (qmail 12726 invoked from network); 9 Jul 2008 15:27:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 9 Jul 2008 15:27:56 -0000 Received: (qmail 69637 invoked by uid 500); 9 Jul 2008 15:27:54 -0000 Delivered-To: apmail-logging-log4j-user-archive@logging.apache.org Received: (qmail 69595 invoked by uid 500); 9 Jul 2008 15:27:53 -0000 Mailing-List: contact log4j-user-help@logging.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Log4J Users List" Reply-To: "Log4J Users List" Delivered-To: mailing list log4j-user@logging.apache.org Received: (qmail 69554 invoked by uid 99); 9 Jul 2008 15:27:53 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Jul 2008 08:27:53 -0700 X-ASF-Spam-Status: No, hits=-4.0 required=10.0 tests=RCVD_IN_DNSWL_MED,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of christian.berwanger@logica.com designates 207.46.51.80 as permitted sender) Received: from [207.46.51.80] (HELO SG2EHSOBE006.bigfish.com) (207.46.51.80) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Jul 2008 15:27:00 +0000 Received: from mail177-sin-R.bigfish.com (10.3.40.3) by SG2EHSOBE006.bigfish.com (10.3.40.26) with Microsoft SMTP Server id 8.1.240.5; Wed, 9 Jul 2008 15:27:17 +0000 Received: from mail177-sin (localhost.localdomain [127.0.0.1]) by mail177-sin-R.bigfish.com (Postfix) with ESMTP id 47AFAA782BE for ; Wed, 9 Jul 2008 15:27:17 +0000 (UTC) X-BigFish: VPS-25(z1091vz542N1432R1b0aM62a3L7efV1805M19c2kzzzzz2fh6bh43j61h) X-Spam-TCS-SCL: 0:0 Received: by mail177-sin (MessageSwitch) id 1215617232684462_3104; Wed, 9 Jul 2008 15:27:12 +0000 (UCT) Received: from c2-ex002.groupinfra.com (unknown [212.123.206.142]) by mail177-sin.bigfish.com (Postfix) with ESMTP id 1FF33B10046 for ; Wed, 9 Jul 2008 15:27:11 +0000 (UTC) Received: from de-ex001.groupinfra.com ([10.48.190.30]) by c2-ex002.groupinfra.com with Microsoft SMTPSVC(6.0.3790.1830); Wed, 9 Jul 2008 17:27:01 +0200 Received: from de-ex004.groupinfra.com ([10.48.190.35]) by de-ex001.groupinfra.com with Microsoft SMTPSVC(6.0.3790.1830); Wed, 9 Jul 2008 17:27:01 +0200 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-Class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: RE: Syslog message is sent twice in the case no log4j configuration file is used Date: Wed, 9 Jul 2008 17:27:00 +0200 Message-ID: <8CF5B3F5110E6C46A06463683F346BE659E2B2@de-ex004.groupinfra.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Syslog message is sent twice in the case no log4j configuration file is used Thread-Index: Acjg44uZemA+aKgXQ4eAIiPtpzW0CgAsYK1AAA2nikAAAt2wIA== From: "Berwanger, Christian" To: "Log4J Users List" X-OriginalArrivalTime: 09 Jul 2008 15:27:01.0139 (UTC) FILETIME=[3BBB8630:01C8E1D8] X-Virus-Checked: Checked by ClamAV on apache.org Thx Heri for answering! Following code unfortunately produces the same problem. I still receive the message twice. = m_logger =3D Logger.getRootLogger(); m_logger.setAdditivity(false); m_syslogAppender =3D new SyslogAppender(); m_syslogAppender.activateOptions(); m_syslogAppender.setLayout(new PatternLayout("%c: %m%n")); m_syslogAppender.setSyslogHost("localhost"); m_logger.addAppender(m_syslogAppender); m_syslogAppender.setFacility(mapFacilityID(this.m_facility)); sendLogMessage(logMessage); m_logger.removeAllAppenders(); The only thing what I could imagine is that in the case there is no configuration file defined the system automatically generates a standard configuration with a standard syslog appender. To avoid this I tried to set the Additivity to false. = I also called the "getAllAppenders()" in order to count the added appenders but I only got the right number of one! Has somebody any other ideas? Christian -----Original Message----- From: Bender Heri [mailto:HBender@Ergonomics.ch] = Sent: Mittwoch, 9. Juli 2008 15:59 To: Log4J Users List Subject: RE: Syslog message is sent twice in the case no log4j configuration file is used My only guess is that setting the additivity flag by code does not have any effect. Or maybe a kind of activateOptions() on the logger must be performed. Why dont you fetch the RootLogger for appending your syslog appender, as you do in your config example? After the log call you clear the appenders anyway. Heri = > -----Original Message----- > From: Berwanger, Christian [mailto:christian.berwanger@logica.com] = > Sent: Wednesday, July 09, 2008 9:27 AM > To: Log4J Users List > Subject: RE: Syslog message is sent twice in the case no = > log4j configuration file is used > = > Nobody has an idea? > = > -----Original Message----- > From: Berwanger, Christian [mailto:christian.berwanger@logica.com] > Sent: Dienstag, 8. Juli 2008 12:15 > To: log4j-user@logging.apache.org > Subject: Syslog message is sent twice in the case no log4j = > configuration file is used > = > Hi log4j comunity, > = > = > = > I'm using the log4j appender in order to send my log message = > to a remote host. I decided not to use the config file = > because the application itself is already using a central = > config file which I want to use to read my configurable data = > (like hostname, port...). However when I'm using the log4j = > API without config file the message is sent twice times. > = > = > = > I read and tried already the hints on the tutorial sites = > without success which threads several ideas for the problem = > of multiple same messages. = > = > = > = > m_logger =3D Logger.getLogger(SecurityEvent.class.getName()); > = > m_logger.setAdditivity(false); > = > m_syslogAppender =3D new SyslogAppender(); > = > m_syslogAppender.activateOptions(); > = > m_syslogAppender.setLayout(new PatternLayout("%c: %m%n")); > = > m_syslogAppender.setSyslogHost("localhost"); > = > m_logger.addAppender(m_syslogAppender); > = > m_syslogAppender.setFacility(mapFacilityID(this.m_facility)); > = > sendLogMessage(logMessage); > = > m_logger.removeAllAppenders(); > = > = > = > However when I tried following configuration file instead it = > worked fine. > = > = > = > # Set root logger level to DEBUG and its only appender to A1. > = > log4j.rootLogger=3DDEBUG, A1 > = > = > = > # A1 is set to be a ConsoleAppender. > = > log4j.appender.A1=3Dorg.apache.log4j.net.SyslogAppender > = > = > = > # A1 uses PatternLayout. > = > log4j.appender.A1.layout=3Dorg.apache.log4j.PatternLayout > = > log4j.appender.A1.SyslogHost=3Dlocalhost > = > = > = > log4j.appender.A1.layout.ConversionPattern=3D%c: %m%n > = > = > = > = > = > How can I get only ONE log message? > = > = > = > Thanks for all help > = > = > = > Christian > = > = > = > = > = > = > = > = > = > = > = > = > = > = > = > = > = > This e-mail and any attachment is for authorised use by the intended > recipient(s) only. It may contain proprietary material, = > confidential information and/or be subject to legal = > privilege. It should not be copied, disclosed to, retained or = > used by, any other party. If you are not an intended = > recipient then please promptly delete this e-mail and any = > attachment and all copies and inform the sender. Thank you. > = > = > This e-mail and any attachment is for authorised use by the = > intended recipient(s) only. It may contain proprietary = > material, confidential information and/or be subject to legal = > privilege. It should not be copied, disclosed to, retained or = > used by, any other party. If you are not an intended = > recipient then please promptly delete this e-mail and any = > attachment and all copies and inform the sender. Thank you. > = > = > = > --------------------------------------------------------------------- > To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org > For additional commands, e-mail: log4j-user-help@logging.apache.org > = > = --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org For additional commands, e-mail: log4j-user-help@logging.apache.org This e-mail and any attachment is for authorised use by the intended recipi= ent(s) only. It may contain proprietary material, confidential information = and/or be subject to legal privilege. It should not be copied, disclosed to= , retained or used by, any other party. If you are not an intended recipien= t then please promptly delete this e-mail and any attachment and all copies= and inform the sender. Thank you. --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org For additional commands, e-mail: log4j-user-help@logging.apache.org