multiple lines of output for the same logging event

View: New views
6 Messages — Rating Filter:   Alert me  

multiple lines of output for the same logging event

by Vasile.Jureschi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

I am using a simple configuration:

DBusMessaging::DBusMessaging(string connection_name){
        //initialize logger
        //TODO  move outside the constructor
        logger = log4cxx::Logger::getLogger("DBus Messaging singleton " );
        BasicConfigurator::configure();
....

and the logging output is being duplicated like this:


0 [0xb7f37700] DEBUG DBus Messaging singleton  null - Connecting to DBUS...
0 [0xb7f37700] DEBUG DBus Messaging singleton  null - Connecting to DBUS...
6 [0xb7f37700] DEBUG DBus Messaging singleton  null - Connected with name to D-BUS with pa.controller
6 [0xb7f37700] DEBUG DBus Messaging singleton  null - Connected with name to D-BUS with pa.controller


This happens with every class that I am using log4cxx with (for some I get 4 lines of output). Is this normal behaviour
or am I doing something wrong ?

Thanks,
Vasile

Re: multiple lines of output for the same logging event

by deepak singh-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The reason could be you are initializing the logger multiple times.
Can you send the code where you are initializing the logger and make sure  that part of code is called just once during entire execution.
Thanks
Deepak

On Sat, Aug 29, 2009 at 10:57 PM, <Vasile.Jureschi@...> wrote:
Hello,

I am using a simple configuration:

DBusMessaging::DBusMessaging(string connection_name){
       //initialize logger
       //TODO  move outside the constructor
       logger = log4cxx::Logger::getLogger("DBus Messaging singleton " );
       BasicConfigurator::configure();
....

and the logging output is being duplicated like this:


0 [0xb7f37700] DEBUG DBus Messaging singleton  null - Connecting to DBUS...
0 [0xb7f37700] DEBUG DBus Messaging singleton  null - Connecting to DBUS...
6 [0xb7f37700] DEBUG DBus Messaging singleton  null - Connected with name to D-BUS with pa.controller
6 [0xb7f37700] DEBUG DBus Messaging singleton  null - Connected with name to D-BUS with pa.controller


This happens with every class that I am using log4cxx with (for some I get 4 lines of output). Is this normal behaviour
or am I doing something wrong ?

Thanks,
Vasile


Re: multiple lines of output for the same logging event

by Vasile.Jureschi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Saturday 29 August 2009 21:01:37 deepak singh wrote:
> The reason could be you are initializing the logger multiple times.
> Can you send the code where you are initializing the logger and make sure
> that part of code is called just once during entire execution.
> Thanks
> Deepak
>

Thanks for the quick reply.

The only init parts are these:

Controller::Controller() {
        //initialize logger
        //TODO  move outside the constructor
        logger = log4cxx::Logger::getLogger("Controller");
        BasicConfigurator::configure();
        logger->setLevel(log4cxx::Level::getTrace());

        //listen for messages
// ListenSignals();
}


Watcher::Watcher(string node_name, int jvm_pid, int tick) {
        //initialize logger
        //TODO  move outside the constructor
        logger = log4cxx::Logger::getLogger("Watcher " + node_name);
        BasicConfigurator::configure();
        logger->setLevel(log4cxx::Level::getDebug());
}

DBusMessaging::DBusMessaging(string connection_name){
        //initialize logger
        //TODO  move outside the constructor
        logger = log4cxx::Logger::getLogger("DBus Messaging singleton " );
        BasicConfigurator::configure();
        logger->setLevel(log4cxx::Level::getDebug());
}
etc

Vasile


> On Sat, Aug 29, 2009 at 10:57 PM, <Vasile.Jureschi@...> wrote:
> > Hello,
> >
> > I am using a simple configuration:
> >
> > DBusMessaging::DBusMessaging(string connection_name){
> >        //initialize logger
> >        //TODO  move outside the constructor
> >        logger = log4cxx::Logger::getLogger("DBus Messaging singleton " );
> >        BasicConfigurator::configure();
> > ....
> >
> > and the logging output is being duplicated like this:
> >
> >
> > 0 [0xb7f37700] DEBUG DBus Messaging singleton  null - Connecting to
> > DBUS... 0 [0xb7f37700] DEBUG DBus Messaging singleton  null - Connecting
> > to DBUS... 6 [0xb7f37700] DEBUG DBus Messaging singleton  null -
> > Connected with name to D-BUS with pa.controller
> > 6 [0xb7f37700] DEBUG DBus Messaging singleton  null - Connected with name
> > to D-BUS with pa.controller
> >
> >
> > This happens with every class that I am using log4cxx with (for some I
> > get 4 lines of output). Is this normal behaviour
> > or am I doing something wrong ?
> >
> > Thanks,
> > Vasile

Re: multiple lines of output for the same logging event

by Curt Arnold-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Aug 29, 2009, at 1:08 PM, Vasile.Jureschi@... wrote:

> On Saturday 29 August 2009 21:01:37 deepak singh wrote:
>> The reason could be you are initializing the logger multiple times.
>> Can you send the code where you are initializing the logger and  
>> make sure
>> that part of code is called just once during entire execution.
>> Thanks
>> Deepak

You are calling BasicConfigurator::configure multiple times (once in  
each constructor).  log4j and log4cxx configurations are cumulative,  
so each call attaches another appender to the root logger.

Re: multiple lines of output for the same logging event

by deepak singh-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

one quick solution would be call reset before every configure call you are making.

On Sun, Aug 30, 2009 at 9:24 AM, Curt Arnold <carnold@...> wrote:

On Aug 29, 2009, at 1:08 PM, Vasile.Jureschi@... wrote:

On Saturday 29 August 2009 21:01:37 deepak singh wrote:
The reason could be you are initializing the logger multiple times.
Can you send the code where you are initializing the logger and make sure
that part of code is called just once during entire execution.
Thanks
Deepak

You are calling BasicConfigurator::configure multiple times (once in each constructor).  log4j and log4cxx configurations are cumulative, so each call attaches another appender to the root logger.


Re: multiple lines of output for the same logging event

by Vasile.Jureschi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sunday 30 August 2009 08:44:13 deepak singh wrote:

> one quick solution would be call reset before every configure call you are
> making.
>
> On Sun, Aug 30, 2009 at 9:24 AM, Curt Arnold <carnold@...> wrote:
> > On Aug 29, 2009, at 1:08 PM, Vasile.Jureschi@... wrote:
> >
> > On Saturday 29 August 2009 21:01:37 deepak singh wrote:
> >>> The reason could be you are initializing the logger multiple times.
> >>> Can you send the code where you are initializing the logger and make
> >>> sure that part of code is called just once during entire execution.
> >>> Thanks
> >>> Deepak
> >
> > You are calling BasicConfigurator::configure multiple times (once in each
> > constructor).  log4j and log4cxx configurations are cumulative, so each
> > call attaches another appender to the root logger.

Thanks, I fixed it.
Vasile