Curt Arnold | 1 Mar 07:10 2011
Picon

Re: Static destruction fiasco?


On Feb 27, 2011, at 1:25 PM, Rhys Ulerich wrote:

> Hi,
> 
> I've noticed that this little test program segfaults beautifully under 0.10
> 
>   #include <log4cxx/logger.h>
> 
>   log4cxx::LoggerPtr logger;
> 
>   int main()
>   {
>       logger = log4cxx::Logger::getLogger("someName");
>       LOG4CXX_WARN(logger, "Stuffstuffstuff");
>       // logger = 0;
>      return 0;
>   }
> 
> but if I uncomment the "logger = 0" statement it runs just fine.  Presumably
> that's because "logger = 0" forces the ObjectPtrT instance behind LoggerPtr to
> destruct logger before other static destruction occurs.
> 
> That said, which of
>   1) Bug
>   2) Don't do that
> does that segfault fall into?
> 
> Thanks,
> Rhys
(Continue reading)

stan.forums | 13 Mar 14:50 2011
Picon

log4cxx chainsaw


2 problems:

1. 
I am having problems connecting log4cxx with chainsaw- I get the following
error:
             Connection lost! :: invalid stream header: 3C6C6F67

this is my log4cxx config:
<appender name="countersFileAppender"
class="org.apache.log4j.XMLSocketAppender">
    < param name="RemoteHost" value="localhost"/>
    < param name="Port" value="9000"/>
    < param name="ReconnectionDelay" value="1000"/>
    < layout class="org.apache.log4j.xml.XMLLayout">
         < param name="properties" value="true" />
         < param name="locationinfo" value="true" />
    </layout>
</appender> 
		
2.
I have reconnectionDelay set to 1000 - which i assume is milliseconds, but i
do not see any connection attempts. why is that?
--

-- 
View this message in context: http://old.nabble.com/log4cxx-chainsaw-tp31137344p31137344.html
Sent from the Log4cxx - Users mailing list archive at Nabble.com.

Yusuf Cinar | 23 Mar 00:37 2011
Picon

Custom Appender

Hi

I am trying to write a custom appender following VectorAppender, here http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/test/cpp/vectorappender.h?view=co, as an example.

However, I am getting an error when calling my custom Appenders constructor:

undefined reference to `log4cxx::VirtualAppender::VirtualAppender()' -- see below in red.

I am not sure what is going on but guessing that I am not linking a library although I am linking log4cxx.a, apr-1.a, aprutil-1.a, xml2.a, expat.a. Is there another library to link when creating a Custom appender inherited from AppenderSkeleton?

Below is the code snippet.iv>

Thanks in advance for any help.

#ifndef VIRTUALAPPENDER_H_
#define VIRTUALAPPENDER_H_

#include <log4cxx/appenderskeleton.h>
#include <log4cxx/spi/loggingevent.h>

namespace log4cxx
{
class VirtualAppender : public AppenderSkeleton
{
    public:
 DECLARE_LOG4CXX_OBJECT(VirtualAppender)
              BEGIN_LOG4CXX_CAST_MAP()
                      LOG4CXX_CAST_ENTRY(VirtualAppender)
                      LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
              END_ LOG4CXX_CAST_MAP()

              VirtualAppender();
              ~VirtualAppender();

       &nbs p;        /**
                This method is called by the AppenderSkeleton#doAppend
                method.
                */
                void append(cons t spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p)
                {
                 LogString test =  event->getMessage();
                }

                void close();

                bool isClosed() const
                        { return closed; }

                bool requiresLayout() const
                        { return false;   }
};

nt>
}

#endif /* VIRTUALAPPENDER_H_ */

My app:

#include <iostream>
using namespace std;

// include log4cxx header files.
#include "log4cxx/logger.h"
#include "log4cxx/basicconfigurator.h"
#include "log4cxx/helpers/exception.h"
#include "VirtualAppender.h"

using namespace log4cxx;
using namespace log4cxx::helpers;

Logger Ptr logger(Logger::getLogger("MyApp"));

int main() {
cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!

    VirtualAppender * vAppender = new VirtualAppender(); // Error happens here
    logger->addAppender(vAppender);
    LOG4CXX_INFO(logger, "Entering application."); div>
    LOG4CXX_INFO(logger, "Exiting application.");

return 0;
}


Chhavi Agarwal | 23 Mar 05:31 2011
Picon

AUTO: Chhavi Agarwal is out of the office (returning 03/25/2011)


I am out of the office until 03/25/2011.

On Vacation.
Please contact swapni ( Swapnil D Joshi )l for any project related queries.

Note: This is an automated response to your message  "Custom Appender" sent
on 3/23/11 5:07:47.

This is the only notification you will receive while this person is away.

Curt Arnold | 24 Mar 03:01 2011
Picon

Re: Custom Appender

First. it would be best for you to define your custom appenders in a namespace other than log4cxx.

Second, you declare a constructor, destructor and close method for VirtualAppender, but you did not
provide an implementation.  Unless you compiled and linked in a file that looked like:

#include "VirtualAppender.h"
log4cxx::VirtualAppender::VirtualAppender() {
}

log4cxx::VirtualAppender::~VirtualAppender() {
}

void log4cxx::VirtualAppender::close() {
}

Then the linker would be expected to complain that there was no implementation provided.
Matthew Bingham | 29 Mar 14:06 2011
Picon

Having trouble getting XMLSocketAppender to reconnect

I have been using XMLSocketAppender without much issue, except for when the connection is lost log4cxx is never reconnecting.  I have ReconnectionDelay set to 1000 and when the connection goes I see log4cxx display "log4cxx: Detected problem with connection: log4cxx: IO Exception : status code = 730053"  This is with a 64 bit build with VS2008.  I configure log4cxx from an xml file and in the the source just call

logger_ = Logger::getLogger("Server");
LOG4CXX_DEBUG(logger_,"Server logging");   
 

Any suggestions?  Below is the log4cxx debug information.  Thanks. 

log4cxx: Threshold ="".
log4cxx: Level value for root is [all].
log4cxx: OptionConverter::toLevel: no class name specified, level=[all]
log4cxx: root level set to ALL
log4cxx: Retreiving an instance of Logger.
log4cxx: Setting [Server] additivity to [true].
log4cxx: Level value for Server is [debug].
log4cxx: OptionConverter::toLevel: no class name specified, level=[debug]
log4cxx: Server level set to DEBUG
log4cxx: Class name: [org.apache.log4j.net.XMLSocketAppender]
log4cxx: Setting option name=[Port], value=[12345]
log4cxx: Setting option name=[RemoteHost], value=[192.168.1.102]
log4cxx: Setting option name=[ReconnectionDelay], value=[1000]
log4cxx: Setting option name=[LocationInfo], value=[true]
log4cxx: Parsing layout of class: "org.apache.log4j.PatternLayout"
log4cxx: Setting option name=[ConversionPattern], value=[%d %-5p [%c] %m%n]
log4cxx: Adding appender named [MyXmlAppenderFormated] to logger [Server].
log4cxx: Retreiving an instance of Logger.
log4cxx: Setting [multicastListener] additivity to [true].
log4cxx: Level value for multicastListener is [warn].
log4cxx: OptionConverter::toLevel: no class name specified, level=[warn]
log4cxx: multicastListener level set to WARN
log4cxx: Detected problem with connection:
log4cxx: IO Exception : status code = 730053


Gmane