Related question: Now i have the socket appender working with the Plain Text Socket appender. However, the message is sent in a serialized way and i think i have to de-serialize using a socket node. Does anybody have a good example of using socket nodes to recieve log4cxx messages and getting them back into original format? Thanks Amit
_____ From: Sarna, Amit [mailto:[EMAIL PROTECTED] Sent: 10 August 2007 08:57 To: 'Log4CXX User' Subject: RE: Socket Appender Hi Rayapudi, The XML appender should be fine for me if (hopefully!) it works in 0.9.7 . Thanks very much for your help and prompt response. Cheers Amit _____ From: Rayapudi Sandeep-mgb376 [mailto:[EMAIL PROTECTED] Sent: 10 August 2007 08:26 To: Log4CXX User Subject: RE: Socket Appender Hi, I was using XML Socket appender. not a plain text. I seen several posts saying plain text socket appender (dont remember exact name) doesnt work. I was using log4cxx version 0.10.0 on linux. --- config file log4j.rootLogger=DEBUG, myappender log4j.appender.myappender=org.apache.log4j.RollingFileAppender log4j.appender.myappender.File=../logs/abc.log log4j.appender.myappender.MaxFileSize=100KB log4j.appender.myappender.MaxBackupIndex=1 log4j.appender.myappender.layout=org.apache.log4j.PatternLayout log4j.appender.myappender.layout.ConversionPattern=%d %-5p - %m%n log4j.appender.SOCK=org.apache.log4j.net.XMLSocketAppender log4j.appender.SOCK.RemoteHost=10.232.15.31 log4j.appender.SOCK.Port=9245 log4j.appender.SOCK.LocationInfo=true --- example code #include <log4cxx/logstring.h> #include <log4cxx/logger.h> #include <log4cxx/basicconfigurator.h> #include <log4cxx/rollingfileappender.h> #include <log4cxx/propertyconfigurator.h> #include <log4cxx/helpers/exception.h> #include <log4cxx/logmanager.h> openLogger() { logger = Logger::getRootLogger(); PropertyConfigurator::configure(LOG4CXX_FILE(pbConfigFile)); LOG4CXX_INFO(logger, "********************* LOG OPEN *********************\n"); } closeLogger() { LOG4CXX_INFO(logger, "********************* LOG CLOSE *********************\n"); LogManager::shutdown(); } logMessage(strBuf) { switch(logLevel) { case LOG_LEVEL_CRIT: case LOG_LEVEL_ERR: LOG4CXX_ERROR(logger, strBuf.c_str()); break; case LOG_LEVEL_WARN: LOG4CXX_WARN(logger,strBuf.c_str()); break; case LOG_LEVEL_INFO: LOG4CXX_INFO(logger, strBuf.c_str()); break; case LOG_LEVEL_DBG: case LOG_LEVEL_TRACE: default: LOG4CXX_DEBUG(logger,strBuf.c_str()); break; } } --- listening program at 10.232.15.31 at port 9245 #!/usr/bin/python import socket import sys s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) host='' port=int("9245") print port s.bind((host, port)) s.listen(1) conn, addr = s.accept() print 'client is at', addr while(1): data=conn.recv(1000) print data _____ From: Sarna, Amit [mailto:[EMAIL PROTECTED] Sent: Friday, August 10, 2007 12:27 PM To: [email protected] Subject: Socket Appender Hi, Does anyone have a workin example (or even does it work?) of using a socket appender (client and server) with non-XML config in log4cxx 0.9.7 ? I want to just send lines of log level ERROR over a socket to another process on the same machine. I'd rather use the released 0.9.7 rather than latest development head as I can't really risk breaking any existing logging that is in place. Thanks in advance Amit ============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html ============================================================================== ============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html ============================================================================== ============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html ==============================================================================
