List Info

Thread: Re: Server side socket usage




Re: Server side socket usage
user name
2008-05-17 06:47:08


Hi

Few months back Amit Sarna sent me a working example for client/server loggers. It uses SockeAppender but it should be easily converted to XMLSocketAppender. Below i am pasting the Amit's email which will help you in building the sample attached with this mail...

Hi Rizwan,

  Sorry for delayed response. This is my work e-mail so can't see it on weekends. I've attached the source and config files in a .RAR file. ; It's a very simple example but enough to show how to do a client and a server. I haven't included make files because our makefiles use a lot of environment vars specific to our app but if you can't get it compiling i can try and rustle one up for you tonight.

 

The config files should be in the same directory as the executables. When you've compiled both, run the server first, then run the client. This should produce two log files, the client one should log as expected, and the server one should log it's own stuff and also messages sent from the client app.

 

If you need any explanation on anything drop me a mail and i'll do my best

 

Cheers

  Amit


--
Rizwan Khalid
Phone: +92 021 2781592
14th Floor, National IT Park, Shahra-e-Faisal
Karachi, Pakistan


 

--------- Original message --------
From: "Curt Arnold" APACHE.ORG>
To: "Log4CXX User" LOGGING.APACHE.ORG>
Subject: [SPAM] Re: Server side socket usage
Date: 05-16-08 01:17


On May 15, 2008, at 9:45 AM, Ruud Bos wrote:

> Hello,
>;
> I'm new to the list, so I have no idea if this question has been
> asked many times before. I hope someone can put me in the right
> direction.
>;
> I'd like to use log4cxx for two applications. One acts as a client
> that needs to send it's logging to a server application using socket
> communication. Both programs are written in C++.
>
> From the few things I could find on the internet about the use of
> the ServerSocket class, I was not able to create something that
> works. Most of these only talk about the client side and use the
> java substitute log4j for the server side.
>
> If someone could point me to some example code, that would be
> extremely helpful.
>
> Thanks in advance,
> Ruud
>


log4cxx 0.9.7 came with an implementation of both the client and
server side for SocketAppender, but used its own format that was not
platform independent. So if the sender and receiver differed in
endianness, character type, int length or the like, bad things would
happen.

log4cxx 0.10.0 replaced that with an implementation that produced a
stream format compatible with log4j's format (the Java serialization
of its LoggingEvent class). This allows interoperability with
Chainsaw and eliminated the platform variation of the format.

There is a huge degree of variability allowed with Java serialization
so it is much easier to write a logging event that can be read by Java
serialization than reliably read a logging event written by Java
serialization. You could write code that read log4cxx's specific take
on it, but that would be unlikely to reliably read events from log4j.

If you were going to receive events from log4cxx, I would suggest
using the XMLSocketAppender as the format would require less custom
code to parse the stream format. I'm sorry, but I'm not aware of any
sample code for it.


  
Re: Server side socket usage
user name
2008-05-19 08:08:37
Thanks!

The only thing is that the SocketNode class seems to be removed in 0.10.0
I will try with 0.9.7

Ruud


On Sat, May 17, 2008 at 1:47 PM, rizwan khalid < rizwankhalidinfinilogic.com">rizwankhalidinfinilogic.com> wrote:


Hi

Few months back Amit Sarna sent me a working example for client/server loggers. It uses SockeAppender but it should be easily converted to XMLSocketAppender. Below i am pasting the Amit's email which will help you in building the sample attached with this mail...

Hi Rizwan,

  Sorry for delayed response. This is my work e-mail so can't see it on weekends. I've attached the source and config files in a .RAR file. ; It's a very simple example but enough to show how to do a client and a server. I haven't included&nbsp;make files because our makefiles use a lot of environment vars specific to our app but if you can't get it compiling i can try and rustle one up for you tonight.

 

The config files should be in the same directory as the executables. When you've compiled both, run the server first, then run the client. This should produce two log files, the client one should log as expected, and the server one should log it's own stuff and also messages sent from the client app.

 

If you need any explanation on anything drop me a mail and i'll do my best

 

Cheers

  Amit


--
Rizwan Khalid
Phone: +92 021 2781592
14th Floor, National IT Park, Shahra-e-Faisal
Karachi, Pakistan


 

--------- Original message --------
From: ";Curt Arnold&quot;
To: "Log4CXX User"
Subject: [SPAM] Re: Server side socket usage
Date: 05-16-08 01:17


On May 15, 2008, at 9:45 AM, Ruud Bos wrote:

&gt; Hello,
>;
> I&#39;m new to the list, so I have no idea if this question has been
> asked many times before. I hope someone can put me in the right
> direction.
>;
> I'd like to use log4cxx for two applications. One acts as a client
> that needs to send it's logging to a server application using socket
> communication. Both programs are written in C++.
>
> From the few things I could find on the internet about the use of
> the ServerSocket class, I was not able to create something that
> works. Most of these only talk about the client side and use the
> java substitute log4j for the server side.
>
&gt; If someone could point me to some example code, that would be
> extremely helpful.
&gt;
> Thanks in advance,
> Ruud
>


log4cxx 0.9.7 came with an implementation of both the client and
server side for SocketAppender, but used its own format that was not
platform independent. So if the sender and receiver differed in
endianness, character type, int length or the like, bad things would
happen.

log4cxx 0.10.0 replaced that with an implementation that produced a
stream format compatible with log4j's format (the Java serialization
of its LoggingEvent class). This allows interoperability with
Chainsaw and eliminated the platform variation of the format.

There is a huge degree of variability allowed with Java serialization
so it is much easier to write a logging event that can be read by Java
serialization than reliably read a logging event written by Java
serialization. You could write code that read log4cxx9;s specific take
on it, but that would be unlikely to reliably read events from log4j.

If you were going to receive events from log4cxx, I would suggest
using the XMLSocketAppender as the format would require less custom
code to parse the stream format. I'm sorry, but I'm not aware of any
sample code for it.



Re: Server side socket usage
user name
2008-05-20 08:26:55
Hi,

The above example works like a charm, thanks a lot!
Does anyone know why this has been removed from log4cxx 0.10.0 ?

Ruud

On Mon, May 19, 2008 at 3:08 PM, Ruud Bos < ruud.bosgmail.com">ruud.bosgmail.com> wrote:
Thanks!

The only thing is that the SocketNode class seems to be removed in 0.10.0
I will try with 0.9.7

Ruud



On Sat, May 17, 2008 at 1:47 PM, rizwan khalid < rizwankhalidinfinilogic.com" target="_blank">rizwankhalidinfinilogic.com> wrote:


Hi

Few months back Amit Sarna sent me a working example for client/server loggers. It uses SockeAppender but it should be easily converted to XMLSocketAppender. Below i am pasting the Amit's email which will help you in building the sample attached with this mail...

Hi Rizwan,

  Sorry for delayed response. This is my work e-mail so can't see it on weekends. I've attached the source and config files in a .RAR file. ; It's a very simple example but enough to show how to do a client and a server. I haven't included&nbsp;make files because our makefiles use a lot of environment vars specific to our app but if you can't get it compiling i can try and rustle one up for you tonight.

 

The config files should be in the same directory as the executables. When you've compiled both, run the server first, then run the client. This should produce two log files, the client one should log as expected, and the server one should log it's own stuff and also messages sent from the client app.

 

If you need any explanation on anything drop me a mail and i'll do my best

 

Cheers

  Amit


--
Rizwan Khalid
Phone: +92 021 2781592
14th Floor, National IT Park, Shahra-e-Faisal
Karachi, Pakistan


&nbsp;

--------- Original message --------
From: ";Curt Arnold&quot;
To: "Log4CXX User"
Subject: [SPAM] Re: Server side socket usage
Date: 05-16-08 01:17


On May 15, 2008, at 9:45 AM, Ruud Bos wrote:

&gt; Hello,
>;
> I&#39;m new to the list, so I have no idea if this question has been
> asked many times before. I hope someone can put me in the right
> direction.
>;
> I'd like to use log4cxx for two applications. One acts as a client
> that needs to send it's logging to a server application using socket
> communication. Both programs are written in C++.
>
> From the few things I could find on the internet about the use of
> the ServerSocket class, I was not able to create something that
> works. Most of these only talk about the client side and use the
> java substitute log4j for the server side.
>
&gt; If someone could point me to some example code, that would be
> extremely helpful.
&gt;
> Thanks in advance,
> Ruud
>


log4cxx 0.9.7 came with an implementation of both the client and
server side for SocketAppender, but used its own format that was not
platform independent. So if the sender and receiver differed in
endianness, character type, int length or the like, bad things would
happen.

log4cxx 0.10.0 replaced that with an implementation that produced a
stream format compatible with log4j's format (the Java serialization
of its LoggingEvent class). This allows interoperability with
Chainsaw and eliminated the platform variation of the format.

There is a huge degree of variability allowed with Java serialization
so it is much easier to write a logging event that can be read by Java
serialization than reliably read a logging event written by Java
serialization. You could write code that read log4cxx9;s specific take
on it, but that would be unlikely to reliably read events from log4j.

If you were going to receive events from log4cxx, I would suggest
using the XMLSocketAppender as the format would require less custom
code to parse the stream format. I'm sorry, but I'm not aware of any
sample code for it.




Re: Server side socket usage
user name
2008-05-20 10:46:45
On May 20, 2008, at 8:26 AM, Ruud Bos wrote:

> Hi,
>
> The above example works like a charm, thanks a lot!
> Does anyone know why this has been removed from log4cxx
0.10.0 ?
>
> Ruud
>

The classes that emulate Java library classes are only there
to  
support log4cxx.  They are not intended to be used a general
purpose  
portable runtime, that is the role for Apache Portable
Runtime (APR).   
If you do use them as a general purpose runtime, you need to
be aware  
that any issues outside of their use by log4cxx will likely
not be  
addressed or supported and that the needs of log4cxx may
result in  
their changing in ways that may affect your use.

SocketNode was removed since no log4cxx code used it.  As
such, having  
it there was just a temptation for someone to use it when
they should  
be using APR.

Re: Server side socket usage
user name
2008-05-23 10:04:37

The classes that emulate Java library classes are only there to support log4cxx.  They are not intended to be used a general purpose portable runtime, that is the role for Apache Portable Runtime (APR).  If you do use them as a general purpose runtime, you need to be aware that any issues outside of their use by log4cxx will likely not be addressed or supported and that the needs of log4cxx may result in their changing in ways that may affect your use.

SocketNode was removed since no log4cxx code used it.  As such, having it there was just a temptation for someone to use it when they should be using APR.


That means I will have to dive into APR.
Thanks for the explanation, though.

Ruud
 

[1-5]

about | contact  Other archives ( Real Estate discussion Medical topics )