On 2008-10-01 12:00, Hoang, Minh-Long (Mission Systems) wrote:
I'm having problem with log4cpp's SyslogAppender.

SyslogAppender "works for me" (tm) but I haven't tried 0.10.x

Steps for troubleshooting:

1) Use some other app to make sure your logging setup is correct. I suggest the simple command line logger from the bsdutil / util-linux project:

http://freshmeat.net/projects/util-linux/

2) Use some facility that is working and being used by other apps on the system before trying some custom LOCAL_X facility. Combining steps 1 and 2 you should be very confident that you are watching the right file before moving on to step 3.

3) Write a simple log4cxx test app and try it. The attached one requires no external config and works fine on my systems with log4cxx 0.9.7.

--
Jacob Anawalt
Gecko Software, Inc.
[EMAIL PROTECTED]
435-752-8026
// 2008-0ct-01T20:30
// log4cxx example of working with an external process that rotates
// log files and sends SIGHUP to the logging app to tell it to close
// and reopen files.
//
// g++ -o syslogAppender syslogAppender.cpp -llog4cxx
//
#include <log4cxx/logger.h>
#include <log4cxx/basicconfigurator.h>
#include <log4cxx/patternlayout.h>
#include <log4cxx/net/syslogappender.h>


int 
main(void)
{
        log4cxx::BasicConfigurator::configure();

        log4cxx::LayoutPtr l(new log4cxx::PatternLayout(
                "%-4r %-5p %c %x - %m"));
        log4cxx::net::SyslogAppenderPtr a(
                new log4cxx::net::SyslogAppender(l
                ,log4cxx::net::SyslogAppender::getFacility("DAEMON")));
        a->setSyslogHost("127.0.0.1");
        a->activateOptions();

        log4cxx::LoggerPtr logger(log4cxx::Logger::getLogger("MyApp"));
        logger->addAppender(a);

        while(true) {
                LOG4CXX_INFO(logger,"beep");
                sleep(15);
        }

        return EXIT_SUCCESS;
}

Reply via email to