I am using log4cxx and recently started working with SocketAppender from here 1. I use the following:
java org.apache.log4j.net.SimpleSocketServer 4712 log4j-server.properties
and am able to write logs on the server. I do also have a local SizeRollover policy setup. This all works fine, until I stop running the SimpleSockerServer. At which point my C++ application crashes, I think after the ReconnectionDelayTime specified in the properties file.
0 0x0000003c5fa0e6fd in write () from /lib64/libpthread.so.0
1 0x00007ffff79eade7 in apr_socket_send () from /usr/lib64/libapr-1.so.0
2 0x00007ffff7d52bb1 in log4cxx::helpers::Socket::write(log4cxx::helpers::ByteBuffer&) () from /usr/lib64/liblog4cxx.so.10
3 0x00007ffff7d595ed in log4cxx::helpers::SocketOutputStream::flush(log4cxx::helpers::Pool&) () from /usr/lib64/liblog4cxx.so.10
4 0x00007ffff7d5468c in log4cxx::net::SocketAppender::append(log4cxx::helpers::ObjectPtrT const&, log4cxx::helpers::Pool&) () from /usr/lib64/liblog4cxx.so.10
5 0x00007ffff7cd7d9d in log4cxx::AppenderSkeleton::doAppend(log4cxx::helpers::ObjectPtrT const&, log4cxx::helpers::Pool&) () from /usr/lib64/liblog4cxx.so.10
6 0x00007ffff7cd50f4 in log4cxx::helpers::AppenderAttachableImpl::appendLoopOnAppenders(log4cxx::helpers::ObjectPtrT const&, log4cxx::helpers::Pool&) () from /usr/lib64/liblog4cxx.so.10
7 0x00007ffff7d1adfd in log4cxx::Logger::callAppenders(log4cxx::helpers::ObjectPtrT const&, log4cxx::helpers::Pool&) const () from /usr/lib64/liblog4cxx.so.10
8 0x00007ffff7d1c4ac in log4cxx::Logger::forcedLog(log4cxx::helpers::ObjectPtrT const&, std::basic_string, std::allocator > const&, log4cxx::spi::LocationInfo const&) const () from /usr/lib64/liblog4cxx.so.10`
My question is, it possible to make log4cxx write logs to a local file in case the server stops? If I start the server again, before the application crashes, SocketAppender does not receive the logs again. How can I get around this problem? Any other suggestions to send logs over the network?