Favicon

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 <at> logica.com] 
Sent: Dienstag, 8. Juli 2008 12:15
To: log4j-user <at> 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 = Logger.getLogger(SecurityEvent.class.getName());

 m_logger.setAdditivity(false);

 m_syslogAppender = new SyslogAppender();

 m_syslogAppender.activateOptions();

 m_syslogAppender.setLayout(new PatternLayout("%c: %m%n"));

(Continue reading)

Bender Heri | 9 Jul 15:58

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 <at> 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 <at> logica.com]
> Sent: Dienstag, 8. Juli 2008 12:15
> To: log4j-user <at> logging.apache.org
> Subject: Syslog message is sent twice in the case no log4j 
> configuration file is used
> 
> Hi log4j comunity,
> 
>  
> 
(Continue reading)

Favicon

RE: Syslog message is sent twice in the case no log4j configuration file is used

Thx Heri for answering!

Following code unfortunately produces the same problem. I still receive
the message twice. 

m_logger = Logger.getRootLogger();
m_logger.setAdditivity(false);
m_syslogAppender = 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 <at> Ergonomics.ch] 
(Continue reading)


Gmane