logging-log4cxx-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rayapudi Sandeep-mgb376" <rsand...@motorola.com>
Subject Problem with XMLSocketAppender
Date Sun, 08 Apr 2007 16:21:06 GMT
I am using XMLSocketAppender and have a problem using it.

I have a client listens on a port and prints logging messages. Seding
logging messages to client using XMLSocketAppender. Strangely, first
LOG4CXX_INFO from logging program is received properly at client (which
is waiting with accept system call) but not subsequent. I am pasting
config file, client file and actual program for reference. I searched
thru mailing lists, but similar problem was not faced by anyone before. 

Config:

log4j.rootLogger=DEBUG, SOCK

log4j.appender.SOCK=org.apache.log4j.net.XMLSocketAppender
log4j.appender.SOCK.RemoteHost=10.232.15.31
log4j.appender.SOCK.Port=9000
log4j.appender.SOCK.LocationInfo=false

Actual program:

int main()
{
    int result = EXIT_SUCCESS;
    try
    {
 
PropertyConfigurator::configure(LOG4CXX_FILE("socket.properties"));
                LoggerPtr logger=Logger::getLogger("SOCK");

                LOG4CXX_INFO(logger, "info message");  ---> this message
is received at remote machine
                LOG4CXX_INFO(logger, "info message1"); ----> from here
on, no message is received
                LOG4CXX_INFO(logger, "info message2");
                LOG4CXX_INFO(logger, "info message3");
                LOG4CXX_WARN(logger, "warn message");
                LOG4CXX_ERROR(logger, "error message");
                LOG4CXX_FATAL(logger, "fatal message");
        }
        catch(std::exception&)
        {
                result = EXIT_FAILURE;
        }

    return result;
}

Client program:

while(1){
sin_size = sizeof(struct sockaddr_in);
if((newsockfd = accept(sockfd, (struct sockaddr *)&their_addr,
(socklen_t*)(&sin_size))) == -1){
        perror("accept");
        }
     n = read(newsockfd,buffer,255);
     if (n < 0) perror("ERROR reading from socket");
     cout<<buffer<<endl;
     fputs(buffer,pFile);

}

Output:

45           if (n < 0) perror("ERROR reading from socket");
(gdb)
48           cout<<buffer<<endl;
(gdb)
<log4j:event logger="SOCK" timestamp="1176053349150" level="INFO"
thread="0xb75df3a0">
<log4j:message><![CDATA[info message]]></log4j:message>
</log4j:event>

49           fputs(buffer,pFile);
(gdb) n
37      n=0;
(gdb)
39      sin_size = sizeof(struct sockaddr_in);
(gdb)
40      if((newsockfd = accept(sockfd, (struct sockaddr *)&their_addr,
(socklen_t*)(&sin_size))) == -1){
(gdb)

----> waited a long here and pressed Ctrl+c

Program received signal SIGINT, Interrupt.
0x00f822bc in accept () from /lib/tls/libc.so.6
(gdb) q
The program is running.  Exit anyway? (y or n) y

Thnx,
Sandeep


Mime
View raw message