You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by "Wilfong, Paul" <pa...@ngc.com> on 2007/08/09 23:26:31 UTC

RE: Where is XMLSocketAppender for XMLSocketReceiver?

I was wondering if this forum post was ever resolved.  If so, would it be possible for the final config files to be posted?  If not, could an overview of the difficulties be provided?

The original issue was to have both Java and C programs logging, using log4j and log4cxx respectively.  The Java program would use SocketAppender, and the C program XMLSocketAppender.  Then, on another machine, SocketReceiver and XMLSocketReceiver would be used, both with RollingFileAppender.

If I have this right, would a Java program need to be written to execute the SocketReceiver and XMLSocketReceiver logic?

Thanks for any help.

______________________________________________________________________________________________________


Hi Claudia,

I'd suggest using SocketAppender and adding a second receiver to your config file (SocketReceiver).

While you would have two receivers in your config file, it should work (all of the received
events - from either receiver - will be handed over to the RollingFileAppender.)

Scott

-----Original Message-----
From: Clᵤia Miazaki [mailto:cmiazaki@itautec-philco.com.br] 
Sent: Wednesday, June 30, 2004 6:06 AM
To: 'Log4J Users List'
Cc: cmiazaki@itautec.com.br
Subject: Where is XMLSocketAppender for XMLSocketReceiver?


Hi,

I have tried Scott's suggestion and the combination of log4cxx's XMLSocketAppender sending
logging events to log4j's XMLSocketReceiver did work but I wonder which appenders should be
used if I wanted to log from log4j itself to a XMLSocketReceiver: I could not find XMLSocketAppender
defined in log4j-1.3alpha.

The issue is that I wanted to use the same XML configuration file for both
C++ and Java apps, all of them sending logging events to the same
XMLSocketReceiver, who will later use a RollingFileAppender.

Regards,
Claudia


-----Mensagem original-----
De: Clᵤia Miazaki [mailto:cmiazaki@itautec-philco.com.br]
Enviada em: sexta-feira, 25 de junho de 2004 15:29
Para: 'Scott Deboy'; 'Log4J Users List'
Cc: cmiazaki@itautec.com.br
Assunto: RES: Log4j SocketServer with Log4cxx SockeAppender


Hi,

Sorry to bother again, but I am a newbie to all this logging and XML as well.

I must be missing something (or maybe many things) because I can't make it work yet. Now I
am using log4j v1.3-alpha from CVS and I did this sequence:

(Step 1) Activation of log4j's SimpleSocketServer with this command:
     java org.apache.log4j.net.SimpleSocketServer 12345 siaclog_server.xml where file "siaclog_server.xml"
is attached bellow and port 12345 is not being used in my machine. The last messages shown
at this point inform:
     INFO - Listening on port 12345
     INFO - Listening on port 12345
     INFO - Waiting to accept a new client
     INFO - Waiting to accept a new client
and then it "hangs" waiting for incoming logging events.

(Step 2) Start-up the C++ application linked to log4cxx.dll (version 0.9.7). This application
parses an XML configuration file called "siaclog_client.xml" (also attached) using DOMConfigurator.

At this point these errors occur at the SimpleSocketServer: ERROR - Exception opening ObjectInputStream
to Socket[addr=/127.0.0.1,port=4845,localport=12345]
java.io.StreamCorruptedException: invalid stream header
        at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
        ...


Another question:
As will also have Java applications sending logging events to this same SimpleSocketServer,
which king of appender should them use? I could not find any XMLSocketAppender at log4j.


Best regards

Claudia Miazaki


-----Mensagem original-----
De: Scott Deboy [mailto:sdeboy@comotivsystems.com]
Enviada em: quarta-feira, 23 de junho de 2004 11:29
Para: Log4J Users List; cmiazaki@itautec-philco.com.br
Assunto: RE: Log4j SocketServer with Log4cxx SockeAppender


(requires the latest version of log4j available from CVS):

On the log4j side, use a simplesocketserver, specifying whichever port you want to receive
java events on, and a log4j config file which includes this receiver plugin definition (or
it's properties-style equivalent):

   <plugin name="Log4JXMLSocketReceiver" class="org.apache.log4j.net.XMLSocketReceiver">
     <param name="Port" value="4447"/>
   </plugin>

You can also configure Chainsaw v2 to use the same receiver and view events in the UI.

Scott

-----Original Message-----
From: Clᵤia Miazaki [mailto:cmiazaki@itautec-philco.com.br]
Sent: Wednesday, June 23, 2004 5:14 AM
To: log4j-user@logging.apache.org
Cc: cmiazaki@itautec.com.br
Subject: Log4j SocketServer with Log4cxx SockeAppender


Hi,

I'm trying to use log4j's SocketServer.java on a listening port to manage logging events coming
 both from Java and C++ applications, using log4j and log4cxx SocketAppenders, respectively.
The SocketServer manages logging events from my Java applications fine, but when it receives
logging events from the C++ applications it gets the following exception:

java.io.StreamCorruptedException: invalid stream header
        at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
        ...

Is this kind of usage impossible? Log4j's SocketServer can only deal with logging events from
other Java apps?

Thanks for any help!

Best regards,

Claudia Miazaki


Re: Where is XMLSocketAppender for XMLSocketReceiver?

Posted by Curt Arnold <ca...@apache.org>.
On Aug 15, 2007, at 1:12 PM, Wilfong, Paul wrote:

> On Aug 15, 2007 at 8:40 AM, Arnold, Curt wrote:
>> I haven't followed this thread closely, but you should
>> consider migrating away from log4j 1.3 to log4j 1.2 plus appropriate
>> companions.
>
> Thanks Curt.
>
> If you read my most recent post you know I finally have achieved these
> goals (all under WindowsXP):
> 1.  Run a Java program that uses log4j, with a SocketAppender, and
> SimpleSocketServer to in turn output to a rolling file.
> 2.  Simultaneously run a C program that uses log4cxx, with a
> XMLSocketAppender, and SimpleSocketServer/XMLSocketReceiver to  
> output to
> the same rolling file.  My current understanding is that the XML
> appender and receiver must be used due to C/Java compatibility issues.
>
> I used 1.3 since it has the XML receiver, and it looked to me like 1.3
> was the latest and greatest from the log4j homepage
> http://logging.apache.org/log4j/docs/index.html. Sorry for the
> misunderstanding.
>
> Based on your input, I now plan to migrate back to 1.2 plus  
> companions.
>
> Is Chainsaw in one of companion packages?  I believe I have looked in
> all of them, but haven't seen it.
>
> I sure appreciate your help.
>

Chainsaw is its own product.  In the last few months, we have  
migrated Chainsaw from using log4j 1.3 to using log4j 1.2 + several  
companions.  The web site is stale since we have not officially  
released any of this work, but there is a staged web site at http:// 
svn.apache.org/repos/asf/logging/site/trunk/docs/index.html that  
shows what the web site should look like when we can push through a  
vote to start releasing these things.  The download links on the  
staged web site anticipate the location of actual releases, so they  
won't work, but would appreciate any feedback on the staged site.   
Will probably cut some new release candidate shortly and any or all  
feedback is appreciated.

It would be technical possible to have log4net and log4cxx's  
SocketAppenders generate binary streams compatible with log4j 1.2.   
It has been an item long on the wishlist (I think it is LOGCXX-7),  
but it would take analysis the Java serialization of  
o.a.l.spi.LoggingEvent and then replicating the binary layout within  
log4cxx and/or log4net.

It would probably be good to have a log4j implementation of  
XMLSocketAppender in extras and I might take a quick shot to put one  
together. 

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


RE: Where is XMLSocketAppender for XMLSocketReceiver?

Posted by "Wilfong, Paul" <pa...@ngc.com>.
On Aug 15, 2007 at 8:40 AM, Arnold, Curt wrote:
> I haven't followed this thread closely, but you should  
> consider migrating away from log4j 1.3 to log4j 1.2 plus appropriate  
> companions.

Thanks Curt.

If you read my most recent post you know I finally have achieved these
goals (all under WindowsXP):
1.  Run a Java program that uses log4j, with a SocketAppender, and
SimpleSocketServer to in turn output to a rolling file. 
2.  Simultaneously run a C program that uses log4cxx, with a
XMLSocketAppender, and SimpleSocketServer/XMLSocketReceiver to output to
the same rolling file.  My current understanding is that the XML
appender and receiver must be used due to C/Java compatibility issues.

I used 1.3 since it has the XML receiver, and it looked to me like 1.3
was the latest and greatest from the log4j homepage
http://logging.apache.org/log4j/docs/index.html. Sorry for the
misunderstanding.

Based on your input, I now plan to migrate back to 1.2 plus companions.

Is Chainsaw in one of companion packages?  I believe I have looked in
all of them, but haven't seen it.

I sure appreciate your help.

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: Where is XMLSocketAppender for XMLSocketReceiver?

Posted by Curt Arnold <ca...@apache.org>.
On Aug 15, 2007, at 9:56 AM, Wilfong, Paul wrote:

> Some progress and new problems...
>
> I found that the XMLDecoder class is not in the jar file  
> "log4j-1.3alpha-8.jar"!
>
> I looked in the other jar files that come in the 1.3alpha-8  
> distribution, and found that XMLDecoder seems to be in "log4j- 
> all-1.3alpha-8.jar".
>
> When I use this instead, I no longer get the "Unable to find  
> decoder" message.
>

log4j 1.3 had split up itself into 8 or so different jars.  The -all-  
jar was an response to restore an all-in-one jar that could be used  
as a replacement for log4j.jar.



> However, now I get the following:
> java.net.MalformedURLException: unknown protocol: dummy
>
> The XMLDecoder code has the following at line 132:   
> inputSource.setSystemId("dummy://log4j.dtd");
> along with some comments regarding something called Crimson.
>
> I'm not sure what to do at this point.  Should I try to remove the  
> "dummy://" and rebuild the class?  Or can I get a previous  
> distribution that might not have this problem?
>

Crimson is the name of the Sun developed XML parser that was provided  
with the first JAXP release (before XML parsing was part of the  
JDK).  It was donated to the ASF and is dormant.  Later JDK's provide  
a rebuilt version of the Apache Xerces 2 project.

I reviewed the code in the SVN and it appears that the decoder has  
always had potential problems, it is just they weren't apparent with  
some parsers and the current parser does some additional checks on  
the URL for the DTD before sending it off to an entity resolver at  
which time we ignore what it did and provide a precanned version of  
the log4j.dtd.   I'd suggest:



Index: src/main/java/org/apache/log4j/xml/XMLDecoder.java
===================================================================
--- src/main/java/org/apache/log4j/xml/XMLDecoder.java  (revision  
566217)
+++ src/main/java/org/apache/log4j/xml/XMLDecoder.java  (working copy)
@@ -68,7 +68,7 @@
       */
    private static final String BEGINPART =
      "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"
-    + "<!DOCTYPE log4j:eventSet SYSTEM \"log4j.dtd\">"
+    + "<!DOCTYPE log4j:eventSet SYSTEM \"http://localhost/log4j.dtd\">"
      + "<log4j:eventSet version=\"1.2\" "
      + "xmlns:log4j=\"http://jakarta.apache.org/log4j/\">";
      /**
@@ -165,7 +165,6 @@
        InputSource inputSource =
          new InputSource(new StringReader(buf.toString()));
-      inputSource.setSystemId("dummy://log4j.dtd");
        document = docBuilder.parse(inputSource);
      } catch (Exception e) {
        e.printStackTrace();


The problem also exists in the receivers companion for log4j 1.2.   
I'll going to add some unit tests around it there and confirm that  
those changes work as expected.  If they do then I commit them plus  
tests to the receivers companion and just the fix to the abandoned  
1.3 branch.  I haven't followed this thread closely, but you should  
consider migrating away from log4j 1.3 to log4j 1.2 plus appropriate  
companions.

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


RE: Where is XMLSocketAppender for XMLSocketReceiver?

Posted by "Wilfong, Paul" <pa...@ngc.com>.
Good progress, but still questions.

I imported the 1.3alpha-8 distribution into Eclipse, then rebuilt.  The project build has errors, but after making sure XMLDecoder is included in the build, I took a chance and went ahead and executed from inside Eclipse.  Now it works!  It also works if the newly built class is executed from a Command Window.

So I can now log from the C program and the Java program simultaneously, through sockets, to SimpleSocketServer, and from there out to a rolling file.  Whew!

I don't understand why running straight from the distribution does not work.  The code used in my local log4j build still has "inputSource.setSystemId("dummy://log4j.dtd") in XMLDecoder.  I’ve double-checked my Classpath setup.

Thanks for any ideas. 

______________________________________________________________ 

-----Original Message-----
From: Wilfong, Paul [mailto:paul.wilfong@ngc.com] 
Sent: Wednesday, August 15, 2007 7:56 AM
To: Log4J Users List
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?

Some progress and new problems...

I found that the XMLDecoder class is not in the jar file "log4j-1.3alpha-8.jar"!

I looked in the other jar files that come in the 1.3alpha-8 distribution, and found that XMLDecoder seems to be in "log4j-all-1.3alpha-8.jar".

When I use this instead, I no longer get the "Unable to find decoder" message.

However, now I get the following:
java.net.MalformedURLException: unknown protocol: dummy

The XMLDecoder code has the following at line 132:  inputSource.setSystemId("dummy://log4j.dtd");
along with some comments regarding something called Crimson.

I'm not sure what to do at this point.  Should I try to remove the "dummy://" and rebuild the class?  Or can I get a previous distribution that might not have this problem?

Thanks for any assistance.
______________________________________________________________ 

-----Original Message-----
From: Wilfong, Paul [mailto:paul.wilfong@ngc.com]
Sent: Wednesday, August 15, 2007 7:52 AM
To: Log4J Users List
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?

I apologize for opening this thread again.  I thought it was wrapped up, but I had misconfigured a file and was fooling myself about the results.

So now, with everything set up, including the XML properties file with the plugin defined, I execute the SimpleSocketServer, and then the C program using log4cxx.

When I do this, SimpleSocketServer reports an error,
"158734 [Thread-0] WARN org.apache.log4j.net.XMLSocketNode - Unable to find decoder"

I have tried to specify a "decoder" parameter in the properties file, with no luck.  The Classpath seems to be set up Ok to me.  I was also thinking of trying to use the SocketServer in place of SimpleSocketServer, to see if that makes any difference.

Any help with this would sure be appreciated.
_______________________________________________________________________________________ 

-----Original Message-----
From: Wilfong, Paul [mailto:paul.wilfong@ngc.com]
Sent: Monday, August 13, 2007 10:31 AM
To: Log4J Users List
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?

With your suggestions, my setup is now working wonderfully.

By the way, I went ahead and purchased the Log4j manual just now and it is definitely a big help to have.

Again, thanks!! 

-----Original Message-----
From: Scott Deboy [mailto:sdeboy@comotivsystems.com]
Sent: Monday, August 13, 2007 10:27 AM
To: Log4J Users List
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?

I think you need to use the xml file format if you are defining receivers/filters.

Scott


-----Original Message-----
From: Wilfong, Paul [mailto:paul.wilfong@ngc.com]
Sent: Monday, August 13, 2007 10:12 AM
To: Log4J Users List
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?

One more question - Is it possible for the config file to be in the "key=value" format, or is XML necessary, for defining the receivers (plugins).

Thanks very much.

-----Original Message-----
From: Wilfong, Paul [mailto:paul.wilfong@ngc.com]
Sent: Monday, August 13, 2007 9:30 AM
To: Log4J Users List
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?

Ah so - Now I get it.  This helps tremendously - Thanks! 

-----Original Message-----
From: Scott Deboy [mailto:sdeboy@comotivsystems.com]
Sent: Monday, August 13, 2007 9:19 AM
To: Log4J Users List
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?

You don't need to write a program for PC2 - any app that loads a log4j configuration file will do - as long as that configuration file contains both the receivers and appenders you need.

This means you can start SimpleSocketServer on PC2 configured with a log4j configuration file which contains two receiver entries and one appender entry.

The receivers will start receiving the events once configuration is complete - the appender will append any events received by the receivers.

Here's an example log4j config file you could use with the SimpleSocketServer (I know SimpleSocketServer has built-in support for listening on a socket - same as SocketReceiver, you could use that if you want instead of adding the socketreceiver section below - otherwise, make sure that's using a different port!):

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration >
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="true"> <appender name="FILE" class="org.apache.log4j.FileAppender">
	<param name="Append" value="false"/>
	<param name="File" value="log.txt"/>
	<layout class="org.apache.log4j.PatternLayout">
		<param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
	</layout>
</appender>   
   
   <plugin name="SocketReceiver" class="org.apache.log4j.net.SocketReceiver">
      <param name="Port" value="7776"/>
   </plugin>

   <plugin name="XMLSocketReceiver" class="org.apache.log4j.net.XMLSocketReceiver">
      <param name="Port" value="7777"/>
   </plugin>
   <root>
      <level value="DEBUG"/>
      <appender-ref ref="FILE"/>
   </root>
</log4j:configuration>

Hope this helps


Scott 


-----Original Message-----
From: Wilfong, Paul [mailto:paul.wilfong@ngc.com]
Sent: Monday, August 13, 2007 8:30 AM
To: Log4J Users List
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?

Thanks very much for the reply!  But I feel I am being dense about this.

I have a PC, call it PC1, running a Java program using SocketAppender with port 7776.  At the same time, PC1 is also running a C++ program using an XMLSocketAppender with port 7777.

Now I have a second PC, call it PC2.  I am looking at your reply to Claudia from long ago:  "While you would have two receivers in your config file, it should work (all of the received events - from either receiver - will be handed over to the RollingFileAppender.)"

This is exactly what I would like to do, but I don't know what you mean by "two receivers in your config file".  Don't I need to write a program for PC2, analogous to the SocketServer program, that listens to 7776 for the PC1 Java program, and 7777 for the PC1 C++ program with XML, and uses a config file with the RollingFileAppender specified?

The "two receivers in your config file" is what throws me.  Does it mean there might be a way to set up PC2 without having to write a new SocketServer-like program?  If so, that would be really great.

Thanks for any help.


-----Original Message-----
From: Scott Deboy [mailto:sdeboy@comotivsystems.com]
Sent: Thursday, August 09, 2007 5:16 PM
To: Log4J Users List
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?

XMLSocketReceiver was written to allow other frameworks (log4cxx, log4php, log4perl, java.util.logging) to send events to log4j over TCP - we already had that ability with SocketAppender/SocketReceiver, so we didn't see a need to write XMLSocketAppender.

Scott Deboy


-----Original Message-----
From: Wilfong, Paul [mailto:paul.wilfong@ngc.com]
Sent: Thursday, August 09, 2007 2:27 PM
To: log4j-user@logging.apache.org
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?


I was wondering if this forum post was ever resolved.  If so, would it be possible for the final config files to be posted?  If not, could an overview of the difficulties be provided?

The original issue was to have both Java and C programs logging, using log4j and log4cxx respectively.  The Java program would use SocketAppender, and the C program XMLSocketAppender.  Then, on another machine, SocketReceiver and XMLSocketReceiver would be used, both with RollingFileAppender.

If I have this right, would a Java program need to be written to execute the SocketReceiver and XMLSocketReceiver logic?

Thanks for any help.

______________________________________________________________________________________________________


Hi Claudia,

I'd suggest using SocketAppender and adding a second receiver to your config file (SocketReceiver).

While you would have two receivers in your config file, it should work (all of the received events - from either receiver - will be handed over to the RollingFileAppender.)

Scott

-----Original Message-----
From: Clᵤia Miazaki [mailto:cmiazaki@itautec-philco.com.br]
Sent: Wednesday, June 30, 2004 6:06 AM
To: 'Log4J Users List'
Cc: cmiazaki@itautec.com.br
Subject: Where is XMLSocketAppender for XMLSocketReceiver?


Hi,

I have tried Scott's suggestion and the combination of log4cxx's XMLSocketAppender sending logging events to log4j's XMLSocketReceiver did work but I wonder which appenders should be used if I wanted to log from log4j itself to a XMLSocketReceiver: I could not find XMLSocketAppender defined in log4j-1.3alpha.

The issue is that I wanted to use the same XML configuration file for both
C++ and Java apps, all of them sending logging events to the same
XMLSocketReceiver, who will later use a RollingFileAppender.

Regards,
Claudia


-----Mensagem original-----
De: Clᵤia Miazaki [mailto:cmiazaki@itautec-philco.com.br]
Enviada em: sexta-feira, 25 de junho de 2004 15:29
Para: 'Scott Deboy'; 'Log4J Users List'
Cc: cmiazaki@itautec.com.br
Assunto: RES: Log4j SocketServer with Log4cxx SockeAppender


Hi,

Sorry to bother again, but I am a newbie to all this logging and XML as well.

I must be missing something (or maybe many things) because I can't make it work yet. Now I am using log4j v1.3-alpha from CVS and I did this sequence:

(Step 1) Activation of log4j's SimpleSocketServer with this command:
     java org.apache.log4j.net.SimpleSocketServer 12345 siaclog_server.xml where file "siaclog_server.xml"
is attached bellow and port 12345 is not being used in my machine. The last messages shown at this point inform:
     INFO - Listening on port 12345
     INFO - Listening on port 12345
     INFO - Waiting to accept a new client
     INFO - Waiting to accept a new client and then it "hangs" waiting for incoming logging events.

(Step 2) Start-up the C++ application linked to log4cxx.dll (version 0.9.7). This application parses an XML configuration file called "siaclog_client.xml" (also attached) using DOMConfigurator.

At this point these errors occur at the SimpleSocketServer: ERROR - Exception opening ObjectInputStream to Socket[addr=/127.0.0.1,port=4845,localport=12345]
java.io.StreamCorruptedException: invalid stream header
        at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
        ...


Another question:
As will also have Java applications sending logging events to this same SimpleSocketServer, which king of appender should them use? I could not find any XMLSocketAppender at log4j.


Best regards

Claudia Miazaki


-----Mensagem original-----
De: Scott Deboy [mailto:sdeboy@comotivsystems.com]
Enviada em: quarta-feira, 23 de junho de 2004 11:29
Para: Log4J Users List; cmiazaki@itautec-philco.com.br
Assunto: RE: Log4j SocketServer with Log4cxx SockeAppender


(requires the latest version of log4j available from CVS):

On the log4j side, use a simplesocketserver, specifying whichever port you want to receive java events on, and a log4j config file which includes this receiver plugin definition (or it's properties-style equivalent):

   <plugin name="Log4JXMLSocketReceiver" class="org.apache.log4j.net.XMLSocketReceiver">
     <param name="Port" value="4447"/>
   </plugin>

You can also configure Chainsaw v2 to use the same receiver and view events in the UI.

Scott

-----Original Message-----
From: Clᵤia Miazaki [mailto:cmiazaki@itautec-philco.com.br]
Sent: Wednesday, June 23, 2004 5:14 AM
To: log4j-user@logging.apache.org
Cc: cmiazaki@itautec.com.br
Subject: Log4j SocketServer with Log4cxx SockeAppender


Hi,

I'm trying to use log4j's SocketServer.java on a listening port to manage logging events coming  both from Java and C++ applications, using log4j and log4cxx SocketAppenders, respectively.
The SocketServer manages logging events from my Java applications fine, but when it receives logging events from the C++ applications it gets the following exception:

java.io.StreamCorruptedException: invalid stream header
        at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
        ...

Is this kind of usage impossible? Log4j's SocketServer can only deal with logging events from other Java apps?

Thanks for any help!

Best regards,

Claudia Miazaki


RE: Where is XMLSocketAppender for XMLSocketReceiver?

Posted by "Wilfong, Paul" <pa...@ngc.com>.
Some progress and new problems...

I found that the XMLDecoder class is not in the jar file "log4j-1.3alpha-8.jar"!

I looked in the other jar files that come in the 1.3alpha-8 distribution, and found that XMLDecoder seems to be in "log4j-all-1.3alpha-8.jar".

When I use this instead, I no longer get the "Unable to find decoder" message.

However, now I get the following:
java.net.MalformedURLException: unknown protocol: dummy

The XMLDecoder code has the following at line 132:  inputSource.setSystemId("dummy://log4j.dtd");
along with some comments regarding something called Crimson.

I'm not sure what to do at this point.  Should I try to remove the "dummy://" and rebuild the class?  Or can I get a previous distribution that might not have this problem?

Thanks for any assistance.
______________________________________________________________ 

-----Original Message-----
From: Wilfong, Paul [mailto:paul.wilfong@ngc.com] 
Sent: Wednesday, August 15, 2007 7:52 AM
To: Log4J Users List
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?

I apologize for opening this thread again.  I thought it was wrapped up, but I had misconfigured a file and was fooling myself about the results.

So now, with everything set up, including the XML properties file with the plugin defined, I execute the SimpleSocketServer, and then the C program using log4cxx.

When I do this, SimpleSocketServer reports an error,
"158734 [Thread-0] WARN org.apache.log4j.net.XMLSocketNode - Unable to find decoder"

I have tried to specify a "decoder" parameter in the properties file, with no luck.  The Classpath seems to be set up Ok to me.  I was also thinking of trying to use the SocketServer in place of SimpleSocketServer, to see if that makes any difference.

Any help with this would sure be appreciated.
_______________________________________________________________________________________ 

-----Original Message-----
From: Wilfong, Paul [mailto:paul.wilfong@ngc.com]
Sent: Monday, August 13, 2007 10:31 AM
To: Log4J Users List
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?

With your suggestions, my setup is now working wonderfully.

By the way, I went ahead and purchased the Log4j manual just now and it is definitely a big help to have.

Again, thanks!! 

-----Original Message-----
From: Scott Deboy [mailto:sdeboy@comotivsystems.com]
Sent: Monday, August 13, 2007 10:27 AM
To: Log4J Users List
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?

I think you need to use the xml file format if you are defining receivers/filters.

Scott


-----Original Message-----
From: Wilfong, Paul [mailto:paul.wilfong@ngc.com]
Sent: Monday, August 13, 2007 10:12 AM
To: Log4J Users List
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?

One more question - Is it possible for the config file to be in the "key=value" format, or is XML necessary, for defining the receivers (plugins).

Thanks very much.

-----Original Message-----
From: Wilfong, Paul [mailto:paul.wilfong@ngc.com]
Sent: Monday, August 13, 2007 9:30 AM
To: Log4J Users List
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?

Ah so - Now I get it.  This helps tremendously - Thanks! 

-----Original Message-----
From: Scott Deboy [mailto:sdeboy@comotivsystems.com]
Sent: Monday, August 13, 2007 9:19 AM
To: Log4J Users List
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?

You don't need to write a program for PC2 - any app that loads a log4j configuration file will do - as long as that configuration file contains both the receivers and appenders you need.

This means you can start SimpleSocketServer on PC2 configured with a log4j configuration file which contains two receiver entries and one appender entry.

The receivers will start receiving the events once configuration is complete - the appender will append any events received by the receivers.

Here's an example log4j config file you could use with the SimpleSocketServer (I know SimpleSocketServer has built-in support for listening on a socket - same as SocketReceiver, you could use that if you want instead of adding the socketreceiver section below - otherwise, make sure that's using a different port!):

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration >
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="true"> <appender name="FILE" class="org.apache.log4j.FileAppender">
	<param name="Append" value="false"/>
	<param name="File" value="log.txt"/>
	<layout class="org.apache.log4j.PatternLayout">
		<param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
	</layout>
</appender>   
   
   <plugin name="SocketReceiver" class="org.apache.log4j.net.SocketReceiver">
      <param name="Port" value="7776"/>
   </plugin>

   <plugin name="XMLSocketReceiver" class="org.apache.log4j.net.XMLSocketReceiver">
      <param name="Port" value="7777"/>
   </plugin>
   <root>
      <level value="DEBUG"/>
      <appender-ref ref="FILE"/>
   </root>
</log4j:configuration>

Hope this helps


Scott 


-----Original Message-----
From: Wilfong, Paul [mailto:paul.wilfong@ngc.com]
Sent: Monday, August 13, 2007 8:30 AM
To: Log4J Users List
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?

Thanks very much for the reply!  But I feel I am being dense about this.

I have a PC, call it PC1, running a Java program using SocketAppender with port 7776.  At the same time, PC1 is also running a C++ program using an XMLSocketAppender with port 7777.

Now I have a second PC, call it PC2.  I am looking at your reply to Claudia from long ago:  "While you would have two receivers in your config file, it should work (all of the received events - from either receiver - will be handed over to the RollingFileAppender.)"

This is exactly what I would like to do, but I don't know what you mean by "two receivers in your config file".  Don't I need to write a program for PC2, analogous to the SocketServer program, that listens to 7776 for the PC1 Java program, and 7777 for the PC1 C++ program with XML, and uses a config file with the RollingFileAppender specified?

The "two receivers in your config file" is what throws me.  Does it mean there might be a way to set up PC2 without having to write a new SocketServer-like program?  If so, that would be really great.

Thanks for any help.


-----Original Message-----
From: Scott Deboy [mailto:sdeboy@comotivsystems.com]
Sent: Thursday, August 09, 2007 5:16 PM
To: Log4J Users List
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?

XMLSocketReceiver was written to allow other frameworks (log4cxx, log4php, log4perl, java.util.logging) to send events to log4j over TCP - we already had that ability with SocketAppender/SocketReceiver, so we didn't see a need to write XMLSocketAppender.

Scott Deboy


-----Original Message-----
From: Wilfong, Paul [mailto:paul.wilfong@ngc.com]
Sent: Thursday, August 09, 2007 2:27 PM
To: log4j-user@logging.apache.org
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?


I was wondering if this forum post was ever resolved.  If so, would it be possible for the final config files to be posted?  If not, could an overview of the difficulties be provided?

The original issue was to have both Java and C programs logging, using log4j and log4cxx respectively.  The Java program would use SocketAppender, and the C program XMLSocketAppender.  Then, on another machine, SocketReceiver and XMLSocketReceiver would be used, both with RollingFileAppender.

If I have this right, would a Java program need to be written to execute the SocketReceiver and XMLSocketReceiver logic?

Thanks for any help.

______________________________________________________________________________________________________


Hi Claudia,

I'd suggest using SocketAppender and adding a second receiver to your config file (SocketReceiver).

While you would have two receivers in your config file, it should work (all of the received events - from either receiver - will be handed over to the RollingFileAppender.)

Scott

-----Original Message-----
From: Clᵤia Miazaki [mailto:cmiazaki@itautec-philco.com.br]
Sent: Wednesday, June 30, 2004 6:06 AM
To: 'Log4J Users List'
Cc: cmiazaki@itautec.com.br
Subject: Where is XMLSocketAppender for XMLSocketReceiver?


Hi,

I have tried Scott's suggestion and the combination of log4cxx's XMLSocketAppender sending logging events to log4j's XMLSocketReceiver did work but I wonder which appenders should be used if I wanted to log from log4j itself to a XMLSocketReceiver: I could not find XMLSocketAppender defined in log4j-1.3alpha.

The issue is that I wanted to use the same XML configuration file for both
C++ and Java apps, all of them sending logging events to the same
XMLSocketReceiver, who will later use a RollingFileAppender.

Regards,
Claudia


-----Mensagem original-----
De: Clᵤia Miazaki [mailto:cmiazaki@itautec-philco.com.br]
Enviada em: sexta-feira, 25 de junho de 2004 15:29
Para: 'Scott Deboy'; 'Log4J Users List'
Cc: cmiazaki@itautec.com.br
Assunto: RES: Log4j SocketServer with Log4cxx SockeAppender


Hi,

Sorry to bother again, but I am a newbie to all this logging and XML as well.

I must be missing something (or maybe many things) because I can't make it work yet. Now I am using log4j v1.3-alpha from CVS and I did this sequence:

(Step 1) Activation of log4j's SimpleSocketServer with this command:
     java org.apache.log4j.net.SimpleSocketServer 12345 siaclog_server.xml where file "siaclog_server.xml"
is attached bellow and port 12345 is not being used in my machine. The last messages shown at this point inform:
     INFO - Listening on port 12345
     INFO - Listening on port 12345
     INFO - Waiting to accept a new client
     INFO - Waiting to accept a new client and then it "hangs" waiting for incoming logging events.

(Step 2) Start-up the C++ application linked to log4cxx.dll (version 0.9.7). This application parses an XML configuration file called "siaclog_client.xml" (also attached) using DOMConfigurator.

At this point these errors occur at the SimpleSocketServer: ERROR - Exception opening ObjectInputStream to Socket[addr=/127.0.0.1,port=4845,localport=12345]
java.io.StreamCorruptedException: invalid stream header
        at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
        ...


Another question:
As will also have Java applications sending logging events to this same SimpleSocketServer, which king of appender should them use? I could not find any XMLSocketAppender at log4j.


Best regards

Claudia Miazaki


-----Mensagem original-----
De: Scott Deboy [mailto:sdeboy@comotivsystems.com]
Enviada em: quarta-feira, 23 de junho de 2004 11:29
Para: Log4J Users List; cmiazaki@itautec-philco.com.br
Assunto: RE: Log4j SocketServer with Log4cxx SockeAppender


(requires the latest version of log4j available from CVS):

On the log4j side, use a simplesocketserver, specifying whichever port you want to receive java events on, and a log4j config file which includes this receiver plugin definition (or it's properties-style equivalent):

   <plugin name="Log4JXMLSocketReceiver" class="org.apache.log4j.net.XMLSocketReceiver">
     <param name="Port" value="4447"/>
   </plugin>

You can also configure Chainsaw v2 to use the same receiver and view events in the UI.

Scott

-----Original Message-----
From: Clᵤia Miazaki [mailto:cmiazaki@itautec-philco.com.br]
Sent: Wednesday, June 23, 2004 5:14 AM
To: log4j-user@logging.apache.org
Cc: cmiazaki@itautec.com.br
Subject: Log4j SocketServer with Log4cxx SockeAppender


Hi,

I'm trying to use log4j's SocketServer.java on a listening port to manage logging events coming  both from Java and C++ applications, using log4j and log4cxx SocketAppenders, respectively.
The SocketServer manages logging events from my Java applications fine, but when it receives logging events from the C++ applications it gets the following exception:

java.io.StreamCorruptedException: invalid stream header
        at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
        ...

Is this kind of usage impossible? Log4j's SocketServer can only deal with logging events from other Java apps?

Thanks for any help!

Best regards,

Claudia Miazaki


RE: Where is XMLSocketAppender for XMLSocketReceiver?

Posted by "Wilfong, Paul" <pa...@ngc.com>.
I apologize for opening this thread again.  I thought it was wrapped up, but I had misconfigured a file and was fooling myself about the results.

So now, with everything set up, including the XML properties file with the plugin defined, I execute the SimpleSocketServer, and then the C program using log4cxx.

When I do this, SimpleSocketServer reports an error,
"158734 [Thread-0] WARN org.apache.log4j.net.XMLSocketNode - Unable to find decoder"

I have tried to specify a "decoder" parameter in the properties file, with no luck.  The Classpath seems to be set up Ok to me.  I was also thinking of trying to use the SocketServer in place of SimpleSocketServer, to see if that makes any difference.

Any help with this would sure be appreciated.
_______________________________________________________________________________________ 

-----Original Message-----
From: Wilfong, Paul [mailto:paul.wilfong@ngc.com] 
Sent: Monday, August 13, 2007 10:31 AM
To: Log4J Users List
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?

With your suggestions, my setup is now working wonderfully.

By the way, I went ahead and purchased the Log4j manual just now and it is definitely a big help to have.

Again, thanks!! 

-----Original Message-----
From: Scott Deboy [mailto:sdeboy@comotivsystems.com]
Sent: Monday, August 13, 2007 10:27 AM
To: Log4J Users List
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?

I think you need to use the xml file format if you are defining receivers/filters.

Scott


-----Original Message-----
From: Wilfong, Paul [mailto:paul.wilfong@ngc.com]
Sent: Monday, August 13, 2007 10:12 AM
To: Log4J Users List
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?

One more question - Is it possible for the config file to be in the "key=value" format, or is XML necessary, for defining the receivers (plugins).

Thanks very much.

-----Original Message-----
From: Wilfong, Paul [mailto:paul.wilfong@ngc.com]
Sent: Monday, August 13, 2007 9:30 AM
To: Log4J Users List
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?

Ah so - Now I get it.  This helps tremendously - Thanks! 

-----Original Message-----
From: Scott Deboy [mailto:sdeboy@comotivsystems.com]
Sent: Monday, August 13, 2007 9:19 AM
To: Log4J Users List
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?

You don't need to write a program for PC2 - any app that loads a log4j configuration file will do - as long as that configuration file contains both the receivers and appenders you need.

This means you can start SimpleSocketServer on PC2 configured with a log4j configuration file which contains two receiver entries and one appender entry.

The receivers will start receiving the events once configuration is complete - the appender will append any events received by the receivers.

Here's an example log4j config file you could use with the SimpleSocketServer (I know SimpleSocketServer has built-in support for listening on a socket - same as SocketReceiver, you could use that if you want instead of adding the socketreceiver section below - otherwise, make sure that's using a different port!):

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration >
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="true"> <appender name="FILE" class="org.apache.log4j.FileAppender">
	<param name="Append" value="false"/>
	<param name="File" value="log.txt"/>
	<layout class="org.apache.log4j.PatternLayout">
		<param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
	</layout>
</appender>   
   
   <plugin name="SocketReceiver" class="org.apache.log4j.net.SocketReceiver">
      <param name="Port" value="7776"/>
   </plugin>

   <plugin name="XMLSocketReceiver" class="org.apache.log4j.net.XMLSocketReceiver">
      <param name="Port" value="7777"/>
   </plugin>
   <root>
      <level value="DEBUG"/>
      <appender-ref ref="FILE"/>
   </root>
</log4j:configuration>

Hope this helps


Scott 


-----Original Message-----
From: Wilfong, Paul [mailto:paul.wilfong@ngc.com]
Sent: Monday, August 13, 2007 8:30 AM
To: Log4J Users List
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?

Thanks very much for the reply!  But I feel I am being dense about this.

I have a PC, call it PC1, running a Java program using SocketAppender with port 7776.  At the same time, PC1 is also running a C++ program using an XMLSocketAppender with port 7777.

Now I have a second PC, call it PC2.  I am looking at your reply to Claudia from long ago:  "While you would have two receivers in your config file, it should work (all of the received events - from either receiver - will be handed over to the RollingFileAppender.)"

This is exactly what I would like to do, but I don't know what you mean by "two receivers in your config file".  Don't I need to write a program for PC2, analogous to the SocketServer program, that listens to 7776 for the PC1 Java program, and 7777 for the PC1 C++ program with XML, and uses a config file with the RollingFileAppender specified?

The "two receivers in your config file" is what throws me.  Does it mean there might be a way to set up PC2 without having to write a new SocketServer-like program?  If so, that would be really great.

Thanks for any help.


-----Original Message-----
From: Scott Deboy [mailto:sdeboy@comotivsystems.com]
Sent: Thursday, August 09, 2007 5:16 PM
To: Log4J Users List
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?

XMLSocketReceiver was written to allow other frameworks (log4cxx, log4php, log4perl, java.util.logging) to send events to log4j over TCP - we already had that ability with SocketAppender/SocketReceiver, so we didn't see a need to write XMLSocketAppender.

Scott Deboy


-----Original Message-----
From: Wilfong, Paul [mailto:paul.wilfong@ngc.com]
Sent: Thursday, August 09, 2007 2:27 PM
To: log4j-user@logging.apache.org
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?


I was wondering if this forum post was ever resolved.  If so, would it be possible for the final config files to be posted?  If not, could an overview of the difficulties be provided?

The original issue was to have both Java and C programs logging, using log4j and log4cxx respectively.  The Java program would use SocketAppender, and the C program XMLSocketAppender.  Then, on another machine, SocketReceiver and XMLSocketReceiver would be used, both with RollingFileAppender.

If I have this right, would a Java program need to be written to execute the SocketReceiver and XMLSocketReceiver logic?

Thanks for any help.

______________________________________________________________________________________________________


Hi Claudia,

I'd suggest using SocketAppender and adding a second receiver to your config file (SocketReceiver).

While you would have two receivers in your config file, it should work (all of the received events - from either receiver - will be handed over to the RollingFileAppender.)

Scott

-----Original Message-----
From: Clᵤia Miazaki [mailto:cmiazaki@itautec-philco.com.br]
Sent: Wednesday, June 30, 2004 6:06 AM
To: 'Log4J Users List'
Cc: cmiazaki@itautec.com.br
Subject: Where is XMLSocketAppender for XMLSocketReceiver?


Hi,

I have tried Scott's suggestion and the combination of log4cxx's XMLSocketAppender sending logging events to log4j's XMLSocketReceiver did work but I wonder which appenders should be used if I wanted to log from log4j itself to a XMLSocketReceiver: I could not find XMLSocketAppender defined in log4j-1.3alpha.

The issue is that I wanted to use the same XML configuration file for both
C++ and Java apps, all of them sending logging events to the same
XMLSocketReceiver, who will later use a RollingFileAppender.

Regards,
Claudia


-----Mensagem original-----
De: Clᵤia Miazaki [mailto:cmiazaki@itautec-philco.com.br]
Enviada em: sexta-feira, 25 de junho de 2004 15:29
Para: 'Scott Deboy'; 'Log4J Users List'
Cc: cmiazaki@itautec.com.br
Assunto: RES: Log4j SocketServer with Log4cxx SockeAppender


Hi,

Sorry to bother again, but I am a newbie to all this logging and XML as well.

I must be missing something (or maybe many things) because I can't make it work yet. Now I am using log4j v1.3-alpha from CVS and I did this sequence:

(Step 1) Activation of log4j's SimpleSocketServer with this command:
     java org.apache.log4j.net.SimpleSocketServer 12345 siaclog_server.xml where file "siaclog_server.xml"
is attached bellow and port 12345 is not being used in my machine. The last messages shown at this point inform:
     INFO - Listening on port 12345
     INFO - Listening on port 12345
     INFO - Waiting to accept a new client
     INFO - Waiting to accept a new client and then it "hangs" waiting for incoming logging events.

(Step 2) Start-up the C++ application linked to log4cxx.dll (version 0.9.7). This application parses an XML configuration file called "siaclog_client.xml" (also attached) using DOMConfigurator.

At this point these errors occur at the SimpleSocketServer: ERROR - Exception opening ObjectInputStream to Socket[addr=/127.0.0.1,port=4845,localport=12345]
java.io.StreamCorruptedException: invalid stream header
        at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
        ...


Another question:
As will also have Java applications sending logging events to this same SimpleSocketServer, which king of appender should them use? I could not find any XMLSocketAppender at log4j.


Best regards

Claudia Miazaki


-----Mensagem original-----
De: Scott Deboy [mailto:sdeboy@comotivsystems.com]
Enviada em: quarta-feira, 23 de junho de 2004 11:29
Para: Log4J Users List; cmiazaki@itautec-philco.com.br
Assunto: RE: Log4j SocketServer with Log4cxx SockeAppender


(requires the latest version of log4j available from CVS):

On the log4j side, use a simplesocketserver, specifying whichever port you want to receive java events on, and a log4j config file which includes this receiver plugin definition (or it's properties-style equivalent):

   <plugin name="Log4JXMLSocketReceiver" class="org.apache.log4j.net.XMLSocketReceiver">
     <param name="Port" value="4447"/>
   </plugin>

You can also configure Chainsaw v2 to use the same receiver and view events in the UI.

Scott

-----Original Message-----
From: Clᵤia Miazaki [mailto:cmiazaki@itautec-philco.com.br]
Sent: Wednesday, June 23, 2004 5:14 AM
To: log4j-user@logging.apache.org
Cc: cmiazaki@itautec.com.br
Subject: Log4j SocketServer with Log4cxx SockeAppender


Hi,

I'm trying to use log4j's SocketServer.java on a listening port to manage logging events coming  both from Java and C++ applications, using log4j and log4cxx SocketAppenders, respectively.
The SocketServer manages logging events from my Java applications fine, but when it receives logging events from the C++ applications it gets the following exception:

java.io.StreamCorruptedException: invalid stream header
        at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
        ...

Is this kind of usage impossible? Log4j's SocketServer can only deal with logging events from other Java apps?

Thanks for any help!

Best regards,

Claudia Miazaki


RE: Where is XMLSocketAppender for XMLSocketReceiver?

Posted by "Wilfong, Paul" <pa...@ngc.com>.
With your suggestions, my setup is now working wonderfully.

By the way, I went ahead and purchased the Log4j manual just now and it is definitely a big help to have.

Again, thanks!! 

-----Original Message-----
From: Scott Deboy [mailto:sdeboy@comotivsystems.com] 
Sent: Monday, August 13, 2007 10:27 AM
To: Log4J Users List
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?

I think you need to use the xml file format if you are defining receivers/filters.

Scott


-----Original Message-----
From: Wilfong, Paul [mailto:paul.wilfong@ngc.com]
Sent: Monday, August 13, 2007 10:12 AM
To: Log4J Users List
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?

One more question - Is it possible for the config file to be in the "key=value" format, or is XML necessary, for defining the receivers (plugins).

Thanks very much.

-----Original Message-----
From: Wilfong, Paul [mailto:paul.wilfong@ngc.com]
Sent: Monday, August 13, 2007 9:30 AM
To: Log4J Users List
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?

Ah so - Now I get it.  This helps tremendously - Thanks! 

-----Original Message-----
From: Scott Deboy [mailto:sdeboy@comotivsystems.com]
Sent: Monday, August 13, 2007 9:19 AM
To: Log4J Users List
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?

You don't need to write a program for PC2 - any app that loads a log4j configuration file will do - as long as that configuration file contains both the receivers and appenders you need.

This means you can start SimpleSocketServer on PC2 configured with a log4j configuration file which contains two receiver entries and one appender entry.

The receivers will start receiving the events once configuration is complete - the appender will append any events received by the receivers.

Here's an example log4j config file you could use with the SimpleSocketServer (I know SimpleSocketServer has built-in support for listening on a socket - same as SocketReceiver, you could use that if you want instead of adding the socketreceiver section below - otherwise, make sure that's using a different port!):

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration >
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="true"> <appender name="FILE" class="org.apache.log4j.FileAppender">
	<param name="Append" value="false"/>
	<param name="File" value="log.txt"/>
	<layout class="org.apache.log4j.PatternLayout">
		<param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
	</layout>
</appender>   
   
   <plugin name="SocketReceiver" class="org.apache.log4j.net.SocketReceiver">
      <param name="Port" value="7776"/>
   </plugin>

   <plugin name="XMLSocketReceiver" class="org.apache.log4j.net.XMLSocketReceiver">
      <param name="Port" value="7777"/>
   </plugin>
   <root>
      <level value="DEBUG"/>
      <appender-ref ref="FILE"/>
   </root>
</log4j:configuration>

Hope this helps


Scott 


-----Original Message-----
From: Wilfong, Paul [mailto:paul.wilfong@ngc.com]
Sent: Monday, August 13, 2007 8:30 AM
To: Log4J Users List
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?

Thanks very much for the reply!  But I feel I am being dense about this.

I have a PC, call it PC1, running a Java program using SocketAppender with port 7776.  At the same time, PC1 is also running a C++ program using an XMLSocketAppender with port 7777.

Now I have a second PC, call it PC2.  I am looking at your reply to Claudia from long ago:  "While you would have two receivers in your config file, it should work (all of the received events - from either receiver - will be handed over to the RollingFileAppender.)"

This is exactly what I would like to do, but I don't know what you mean by "two receivers in your config file".  Don't I need to write a program for PC2, analogous to the SocketServer program, that listens to 7776 for the PC1 Java program, and 7777 for the PC1 C++ program with XML, and uses a config file with the RollingFileAppender specified?

The "two receivers in your config file" is what throws me.  Does it mean there might be a way to set up PC2 without having to write a new SocketServer-like program?  If so, that would be really great.

Thanks for any help.


-----Original Message-----
From: Scott Deboy [mailto:sdeboy@comotivsystems.com]
Sent: Thursday, August 09, 2007 5:16 PM
To: Log4J Users List
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?

XMLSocketReceiver was written to allow other frameworks (log4cxx, log4php, log4perl, java.util.logging) to send events to log4j over TCP - we already had that ability with SocketAppender/SocketReceiver, so we didn't see a need to write XMLSocketAppender.

Scott Deboy


-----Original Message-----
From: Wilfong, Paul [mailto:paul.wilfong@ngc.com]
Sent: Thursday, August 09, 2007 2:27 PM
To: log4j-user@logging.apache.org
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?


I was wondering if this forum post was ever resolved.  If so, would it be possible for the final config files to be posted?  If not, could an overview of the difficulties be provided?

The original issue was to have both Java and C programs logging, using log4j and log4cxx respectively.  The Java program would use SocketAppender, and the C program XMLSocketAppender.  Then, on another machine, SocketReceiver and XMLSocketReceiver would be used, both with RollingFileAppender.

If I have this right, would a Java program need to be written to execute the SocketReceiver and XMLSocketReceiver logic?

Thanks for any help.

______________________________________________________________________________________________________


Hi Claudia,

I'd suggest using SocketAppender and adding a second receiver to your config file (SocketReceiver).

While you would have two receivers in your config file, it should work (all of the received events - from either receiver - will be handed over to the RollingFileAppender.)

Scott

-----Original Message-----
From: Clᵤia Miazaki [mailto:cmiazaki@itautec-philco.com.br]
Sent: Wednesday, June 30, 2004 6:06 AM
To: 'Log4J Users List'
Cc: cmiazaki@itautec.com.br
Subject: Where is XMLSocketAppender for XMLSocketReceiver?


Hi,

I have tried Scott's suggestion and the combination of log4cxx's XMLSocketAppender sending logging events to log4j's XMLSocketReceiver did work but I wonder which appenders should be used if I wanted to log from log4j itself to a XMLSocketReceiver: I could not find XMLSocketAppender defined in log4j-1.3alpha.

The issue is that I wanted to use the same XML configuration file for both
C++ and Java apps, all of them sending logging events to the same
XMLSocketReceiver, who will later use a RollingFileAppender.

Regards,
Claudia


-----Mensagem original-----
De: Clᵤia Miazaki [mailto:cmiazaki@itautec-philco.com.br]
Enviada em: sexta-feira, 25 de junho de 2004 15:29
Para: 'Scott Deboy'; 'Log4J Users List'
Cc: cmiazaki@itautec.com.br
Assunto: RES: Log4j SocketServer with Log4cxx SockeAppender


Hi,

Sorry to bother again, but I am a newbie to all this logging and XML as well.

I must be missing something (or maybe many things) because I can't make it work yet. Now I am using log4j v1.3-alpha from CVS and I did this sequence:

(Step 1) Activation of log4j's SimpleSocketServer with this command:
     java org.apache.log4j.net.SimpleSocketServer 12345 siaclog_server.xml where file "siaclog_server.xml"
is attached bellow and port 12345 is not being used in my machine. The last messages shown at this point inform:
     INFO - Listening on port 12345
     INFO - Listening on port 12345
     INFO - Waiting to accept a new client
     INFO - Waiting to accept a new client and then it "hangs" waiting for incoming logging events.

(Step 2) Start-up the C++ application linked to log4cxx.dll (version 0.9.7). This application parses an XML configuration file called "siaclog_client.xml" (also attached) using DOMConfigurator.

At this point these errors occur at the SimpleSocketServer: ERROR - Exception opening ObjectInputStream to Socket[addr=/127.0.0.1,port=4845,localport=12345]
java.io.StreamCorruptedException: invalid stream header
        at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
        ...


Another question:
As will also have Java applications sending logging events to this same SimpleSocketServer, which king of appender should them use? I could not find any XMLSocketAppender at log4j.


Best regards

Claudia Miazaki


-----Mensagem original-----
De: Scott Deboy [mailto:sdeboy@comotivsystems.com]
Enviada em: quarta-feira, 23 de junho de 2004 11:29
Para: Log4J Users List; cmiazaki@itautec-philco.com.br
Assunto: RE: Log4j SocketServer with Log4cxx SockeAppender


(requires the latest version of log4j available from CVS):

On the log4j side, use a simplesocketserver, specifying whichever port you want to receive java events on, and a log4j config file which includes this receiver plugin definition (or it's properties-style equivalent):

   <plugin name="Log4JXMLSocketReceiver" class="org.apache.log4j.net.XMLSocketReceiver">
     <param name="Port" value="4447"/>
   </plugin>

You can also configure Chainsaw v2 to use the same receiver and view events in the UI.

Scott

-----Original Message-----
From: Clᵤia Miazaki [mailto:cmiazaki@itautec-philco.com.br]
Sent: Wednesday, June 23, 2004 5:14 AM
To: log4j-user@logging.apache.org
Cc: cmiazaki@itautec.com.br
Subject: Log4j SocketServer with Log4cxx SockeAppender


Hi,

I'm trying to use log4j's SocketServer.java on a listening port to manage logging events coming  both from Java and C++ applications, using log4j and log4cxx SocketAppenders, respectively.
The SocketServer manages logging events from my Java applications fine, but when it receives logging events from the C++ applications it gets the following exception:

java.io.StreamCorruptedException: invalid stream header
        at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
        ...

Is this kind of usage impossible? Log4j's SocketServer can only deal with logging events from other Java apps?

Thanks for any help!

Best regards,

Claudia Miazaki


RE: Where is XMLSocketAppender for XMLSocketReceiver?

Posted by Scott Deboy <sd...@comotivsystems.com>.
I think you need to use the xml file format if you are defining receivers/filters.

Scott


-----Original Message-----
From: Wilfong, Paul [mailto:paul.wilfong@ngc.com] 
Sent: Monday, August 13, 2007 10:12 AM
To: Log4J Users List
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?

One more question - Is it possible for the config file to be in the "key=value" format, or is XML necessary, for defining the receivers (plugins).

Thanks very much.

-----Original Message-----
From: Wilfong, Paul [mailto:paul.wilfong@ngc.com] 
Sent: Monday, August 13, 2007 9:30 AM
To: Log4J Users List
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?

Ah so - Now I get it.  This helps tremendously - Thanks! 

-----Original Message-----
From: Scott Deboy [mailto:sdeboy@comotivsystems.com]
Sent: Monday, August 13, 2007 9:19 AM
To: Log4J Users List
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?

You don't need to write a program for PC2 - any app that loads a log4j configuration file will do - as long as that configuration file contains both the receivers and appenders you need.

This means you can start SimpleSocketServer on PC2 configured with a log4j configuration file which contains two receiver entries and one appender entry.

The receivers will start receiving the events once configuration is complete - the appender will append any events received by the receivers.

Here's an example log4j config file you could use with the SimpleSocketServer (I know SimpleSocketServer has built-in support for listening on a socket - same as SocketReceiver, you could use that if you want instead of adding the socketreceiver section below - otherwise, make sure that's using a different port!):

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration >
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="true"> <appender name="FILE" class="org.apache.log4j.FileAppender">
	<param name="Append" value="false"/>
	<param name="File" value="log.txt"/>
	<layout class="org.apache.log4j.PatternLayout">
		<param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
	</layout>
</appender>   
   
   <plugin name="SocketReceiver" class="org.apache.log4j.net.SocketReceiver">
      <param name="Port" value="7776"/>
   </plugin>

   <plugin name="XMLSocketReceiver" class="org.apache.log4j.net.XMLSocketReceiver">
      <param name="Port" value="7777"/>
   </plugin>
   <root>
      <level value="DEBUG"/>
      <appender-ref ref="FILE"/>
   </root>
</log4j:configuration>

Hope this helps


Scott 


-----Original Message-----
From: Wilfong, Paul [mailto:paul.wilfong@ngc.com]
Sent: Monday, August 13, 2007 8:30 AM
To: Log4J Users List
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?

Thanks very much for the reply!  But I feel I am being dense about this.

I have a PC, call it PC1, running a Java program using SocketAppender with port 7776.  At the same time, PC1 is also running a C++ program using an XMLSocketAppender with port 7777.

Now I have a second PC, call it PC2.  I am looking at your reply to Claudia from long ago:  "While you would have two receivers in your config file, it should work (all of the received events - from either receiver - will be handed over to the RollingFileAppender.)"

This is exactly what I would like to do, but I don't know what you mean by "two receivers in your config file".  Don't I need to write a program for PC2, analogous to the SocketServer program, that listens to 7776 for the PC1 Java program, and 7777 for the PC1 C++ program with XML, and uses a config file with the RollingFileAppender specified?

The "two receivers in your config file" is what throws me.  Does it mean there might be a way to set up PC2 without having to write a new SocketServer-like program?  If so, that would be really great.

Thanks for any help.


-----Original Message-----
From: Scott Deboy [mailto:sdeboy@comotivsystems.com]
Sent: Thursday, August 09, 2007 5:16 PM
To: Log4J Users List
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?

XMLSocketReceiver was written to allow other frameworks (log4cxx, log4php, log4perl, java.util.logging) to send events to log4j over TCP - we already had that ability with SocketAppender/SocketReceiver, so we didn't see a need to write XMLSocketAppender.

Scott Deboy


-----Original Message-----
From: Wilfong, Paul [mailto:paul.wilfong@ngc.com]
Sent: Thursday, August 09, 2007 2:27 PM
To: log4j-user@logging.apache.org
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?


I was wondering if this forum post was ever resolved.  If so, would it be possible for the final config files to be posted?  If not, could an overview of the difficulties be provided?

The original issue was to have both Java and C programs logging, using log4j and log4cxx respectively.  The Java program would use SocketAppender, and the C program XMLSocketAppender.  Then, on another machine, SocketReceiver and XMLSocketReceiver would be used, both with RollingFileAppender.

If I have this right, would a Java program need to be written to execute the SocketReceiver and XMLSocketReceiver logic?

Thanks for any help.

______________________________________________________________________________________________________


Hi Claudia,

I'd suggest using SocketAppender and adding a second receiver to your config file (SocketReceiver).

While you would have two receivers in your config file, it should work (all of the received events - from either receiver - will be handed over to the RollingFileAppender.)

Scott

-----Original Message-----
From: Clᵤia Miazaki [mailto:cmiazaki@itautec-philco.com.br]
Sent: Wednesday, June 30, 2004 6:06 AM
To: 'Log4J Users List'
Cc: cmiazaki@itautec.com.br
Subject: Where is XMLSocketAppender for XMLSocketReceiver?


Hi,

I have tried Scott's suggestion and the combination of log4cxx's XMLSocketAppender sending logging events to log4j's XMLSocketReceiver did work but I wonder which appenders should be used if I wanted to log from log4j itself to a XMLSocketReceiver: I could not find XMLSocketAppender defined in log4j-1.3alpha.

The issue is that I wanted to use the same XML configuration file for both
C++ and Java apps, all of them sending logging events to the same
XMLSocketReceiver, who will later use a RollingFileAppender.

Regards,
Claudia


-----Mensagem original-----
De: Clᵤia Miazaki [mailto:cmiazaki@itautec-philco.com.br]
Enviada em: sexta-feira, 25 de junho de 2004 15:29
Para: 'Scott Deboy'; 'Log4J Users List'
Cc: cmiazaki@itautec.com.br
Assunto: RES: Log4j SocketServer with Log4cxx SockeAppender


Hi,

Sorry to bother again, but I am a newbie to all this logging and XML as well.

I must be missing something (or maybe many things) because I can't make it work yet. Now I am using log4j v1.3-alpha from CVS and I did this sequence:

(Step 1) Activation of log4j's SimpleSocketServer with this command:
     java org.apache.log4j.net.SimpleSocketServer 12345 siaclog_server.xml where file "siaclog_server.xml"
is attached bellow and port 12345 is not being used in my machine. The last messages shown at this point inform:
     INFO - Listening on port 12345
     INFO - Listening on port 12345
     INFO - Waiting to accept a new client
     INFO - Waiting to accept a new client and then it "hangs" waiting for incoming logging events.

(Step 2) Start-up the C++ application linked to log4cxx.dll (version 0.9.7). This application parses an XML configuration file called "siaclog_client.xml" (also attached) using DOMConfigurator.

At this point these errors occur at the SimpleSocketServer: ERROR - Exception opening ObjectInputStream to Socket[addr=/127.0.0.1,port=4845,localport=12345]
java.io.StreamCorruptedException: invalid stream header
        at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
        ...


Another question:
As will also have Java applications sending logging events to this same SimpleSocketServer, which king of appender should them use? I could not find any XMLSocketAppender at log4j.


Best regards

Claudia Miazaki


-----Mensagem original-----
De: Scott Deboy [mailto:sdeboy@comotivsystems.com]
Enviada em: quarta-feira, 23 de junho de 2004 11:29
Para: Log4J Users List; cmiazaki@itautec-philco.com.br
Assunto: RE: Log4j SocketServer with Log4cxx SockeAppender


(requires the latest version of log4j available from CVS):

On the log4j side, use a simplesocketserver, specifying whichever port you want to receive java events on, and a log4j config file which includes this receiver plugin definition (or it's properties-style equivalent):

   <plugin name="Log4JXMLSocketReceiver" class="org.apache.log4j.net.XMLSocketReceiver">
     <param name="Port" value="4447"/>
   </plugin>

You can also configure Chainsaw v2 to use the same receiver and view events in the UI.

Scott

-----Original Message-----
From: Clᵤia Miazaki [mailto:cmiazaki@itautec-philco.com.br]
Sent: Wednesday, June 23, 2004 5:14 AM
To: log4j-user@logging.apache.org
Cc: cmiazaki@itautec.com.br
Subject: Log4j SocketServer with Log4cxx SockeAppender


Hi,

I'm trying to use log4j's SocketServer.java on a listening port to manage logging events coming  both from Java and C++ applications, using log4j and log4cxx SocketAppenders, respectively.
The SocketServer manages logging events from my Java applications fine, but when it receives logging events from the C++ applications it gets the following exception:

java.io.StreamCorruptedException: invalid stream header
        at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
        ...

Is this kind of usage impossible? Log4j's SocketServer can only deal with logging events from other Java apps?

Thanks for any help!

Best regards,

Claudia Miazaki


RE: Where is XMLSocketAppender for XMLSocketReceiver?

Posted by "Wilfong, Paul" <pa...@ngc.com>.
One more question - Is it possible for the config file to be in the "key=value" format, or is XML necessary, for defining the receivers (plugins).

Thanks very much.

-----Original Message-----
From: Wilfong, Paul [mailto:paul.wilfong@ngc.com] 
Sent: Monday, August 13, 2007 9:30 AM
To: Log4J Users List
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?

Ah so - Now I get it.  This helps tremendously - Thanks! 

-----Original Message-----
From: Scott Deboy [mailto:sdeboy@comotivsystems.com]
Sent: Monday, August 13, 2007 9:19 AM
To: Log4J Users List
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?

You don't need to write a program for PC2 - any app that loads a log4j configuration file will do - as long as that configuration file contains both the receivers and appenders you need.

This means you can start SimpleSocketServer on PC2 configured with a log4j configuration file which contains two receiver entries and one appender entry.

The receivers will start receiving the events once configuration is complete - the appender will append any events received by the receivers.

Here's an example log4j config file you could use with the SimpleSocketServer (I know SimpleSocketServer has built-in support for listening on a socket - same as SocketReceiver, you could use that if you want instead of adding the socketreceiver section below - otherwise, make sure that's using a different port!):

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration >
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="true"> <appender name="FILE" class="org.apache.log4j.FileAppender">
	<param name="Append" value="false"/>
	<param name="File" value="log.txt"/>
	<layout class="org.apache.log4j.PatternLayout">
		<param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
	</layout>
</appender>   
   
   <plugin name="SocketReceiver" class="org.apache.log4j.net.SocketReceiver">
      <param name="Port" value="7776"/>
   </plugin>

   <plugin name="XMLSocketReceiver" class="org.apache.log4j.net.XMLSocketReceiver">
      <param name="Port" value="7777"/>
   </plugin>
   <root>
      <level value="DEBUG"/>
      <appender-ref ref="FILE"/>
   </root>
</log4j:configuration>

Hope this helps


Scott 


-----Original Message-----
From: Wilfong, Paul [mailto:paul.wilfong@ngc.com]
Sent: Monday, August 13, 2007 8:30 AM
To: Log4J Users List
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?

Thanks very much for the reply!  But I feel I am being dense about this.

I have a PC, call it PC1, running a Java program using SocketAppender with port 7776.  At the same time, PC1 is also running a C++ program using an XMLSocketAppender with port 7777.

Now I have a second PC, call it PC2.  I am looking at your reply to Claudia from long ago:  "While you would have two receivers in your config file, it should work (all of the received events - from either receiver - will be handed over to the RollingFileAppender.)"

This is exactly what I would like to do, but I don't know what you mean by "two receivers in your config file".  Don't I need to write a program for PC2, analogous to the SocketServer program, that listens to 7776 for the PC1 Java program, and 7777 for the PC1 C++ program with XML, and uses a config file with the RollingFileAppender specified?

The "two receivers in your config file" is what throws me.  Does it mean there might be a way to set up PC2 without having to write a new SocketServer-like program?  If so, that would be really great.

Thanks for any help.


-----Original Message-----
From: Scott Deboy [mailto:sdeboy@comotivsystems.com]
Sent: Thursday, August 09, 2007 5:16 PM
To: Log4J Users List
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?

XMLSocketReceiver was written to allow other frameworks (log4cxx, log4php, log4perl, java.util.logging) to send events to log4j over TCP - we already had that ability with SocketAppender/SocketReceiver, so we didn't see a need to write XMLSocketAppender.

Scott Deboy


-----Original Message-----
From: Wilfong, Paul [mailto:paul.wilfong@ngc.com]
Sent: Thursday, August 09, 2007 2:27 PM
To: log4j-user@logging.apache.org
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?


I was wondering if this forum post was ever resolved.  If so, would it be possible for the final config files to be posted?  If not, could an overview of the difficulties be provided?

The original issue was to have both Java and C programs logging, using log4j and log4cxx respectively.  The Java program would use SocketAppender, and the C program XMLSocketAppender.  Then, on another machine, SocketReceiver and XMLSocketReceiver would be used, both with RollingFileAppender.

If I have this right, would a Java program need to be written to execute the SocketReceiver and XMLSocketReceiver logic?

Thanks for any help.

______________________________________________________________________________________________________


Hi Claudia,

I'd suggest using SocketAppender and adding a second receiver to your config file (SocketReceiver).

While you would have two receivers in your config file, it should work (all of the received events - from either receiver - will be handed over to the RollingFileAppender.)

Scott

-----Original Message-----
From: Clᵤia Miazaki [mailto:cmiazaki@itautec-philco.com.br]
Sent: Wednesday, June 30, 2004 6:06 AM
To: 'Log4J Users List'
Cc: cmiazaki@itautec.com.br
Subject: Where is XMLSocketAppender for XMLSocketReceiver?


Hi,

I have tried Scott's suggestion and the combination of log4cxx's XMLSocketAppender sending logging events to log4j's XMLSocketReceiver did work but I wonder which appenders should be used if I wanted to log from log4j itself to a XMLSocketReceiver: I could not find XMLSocketAppender defined in log4j-1.3alpha.

The issue is that I wanted to use the same XML configuration file for both
C++ and Java apps, all of them sending logging events to the same
XMLSocketReceiver, who will later use a RollingFileAppender.

Regards,
Claudia


-----Mensagem original-----
De: Clᵤia Miazaki [mailto:cmiazaki@itautec-philco.com.br]
Enviada em: sexta-feira, 25 de junho de 2004 15:29
Para: 'Scott Deboy'; 'Log4J Users List'
Cc: cmiazaki@itautec.com.br
Assunto: RES: Log4j SocketServer with Log4cxx SockeAppender


Hi,

Sorry to bother again, but I am a newbie to all this logging and XML as well.

I must be missing something (or maybe many things) because I can't make it work yet. Now I am using log4j v1.3-alpha from CVS and I did this sequence:

(Step 1) Activation of log4j's SimpleSocketServer with this command:
     java org.apache.log4j.net.SimpleSocketServer 12345 siaclog_server.xml where file "siaclog_server.xml"
is attached bellow and port 12345 is not being used in my machine. The last messages shown at this point inform:
     INFO - Listening on port 12345
     INFO - Listening on port 12345
     INFO - Waiting to accept a new client
     INFO - Waiting to accept a new client and then it "hangs" waiting for incoming logging events.

(Step 2) Start-up the C++ application linked to log4cxx.dll (version 0.9.7). This application parses an XML configuration file called "siaclog_client.xml" (also attached) using DOMConfigurator.

At this point these errors occur at the SimpleSocketServer: ERROR - Exception opening ObjectInputStream to Socket[addr=/127.0.0.1,port=4845,localport=12345]
java.io.StreamCorruptedException: invalid stream header
        at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
        ...


Another question:
As will also have Java applications sending logging events to this same SimpleSocketServer, which king of appender should them use? I could not find any XMLSocketAppender at log4j.


Best regards

Claudia Miazaki


-----Mensagem original-----
De: Scott Deboy [mailto:sdeboy@comotivsystems.com]
Enviada em: quarta-feira, 23 de junho de 2004 11:29
Para: Log4J Users List; cmiazaki@itautec-philco.com.br
Assunto: RE: Log4j SocketServer with Log4cxx SockeAppender


(requires the latest version of log4j available from CVS):

On the log4j side, use a simplesocketserver, specifying whichever port you want to receive java events on, and a log4j config file which includes this receiver plugin definition (or it's properties-style equivalent):

   <plugin name="Log4JXMLSocketReceiver" class="org.apache.log4j.net.XMLSocketReceiver">
     <param name="Port" value="4447"/>
   </plugin>

You can also configure Chainsaw v2 to use the same receiver and view events in the UI.

Scott

-----Original Message-----
From: Clᵤia Miazaki [mailto:cmiazaki@itautec-philco.com.br]
Sent: Wednesday, June 23, 2004 5:14 AM
To: log4j-user@logging.apache.org
Cc: cmiazaki@itautec.com.br
Subject: Log4j SocketServer with Log4cxx SockeAppender


Hi,

I'm trying to use log4j's SocketServer.java on a listening port to manage logging events coming  both from Java and C++ applications, using log4j and log4cxx SocketAppenders, respectively.
The SocketServer manages logging events from my Java applications fine, but when it receives logging events from the C++ applications it gets the following exception:

java.io.StreamCorruptedException: invalid stream header
        at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
        ...

Is this kind of usage impossible? Log4j's SocketServer can only deal with logging events from other Java apps?

Thanks for any help!

Best regards,

Claudia Miazaki


RE: Where is XMLSocketAppender for XMLSocketReceiver?

Posted by "Wilfong, Paul" <pa...@ngc.com>.
Ah so - Now I get it.  This helps tremendously - Thanks! 

-----Original Message-----
From: Scott Deboy [mailto:sdeboy@comotivsystems.com] 
Sent: Monday, August 13, 2007 9:19 AM
To: Log4J Users List
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?

You don't need to write a program for PC2 - any app that loads a log4j configuration file will do - as long as that configuration file contains both the receivers and appenders you need.

This means you can start SimpleSocketServer on PC2 configured with a log4j configuration file which contains two receiver entries and one appender entry.

The receivers will start receiving the events once configuration is complete - the appender will append any events received by the receivers.

Here's an example log4j config file you could use with the SimpleSocketServer (I know SimpleSocketServer has built-in support for listening on a socket - same as SocketReceiver, you could use that if you want instead of adding the socketreceiver section below - otherwise, make sure that's using a different port!):

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration >
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="true"> <appender name="FILE" class="org.apache.log4j.FileAppender">
	<param name="Append" value="false"/>
	<param name="File" value="log.txt"/>
	<layout class="org.apache.log4j.PatternLayout">
		<param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
	</layout>
</appender>   
   
   <plugin name="SocketReceiver" class="org.apache.log4j.net.SocketReceiver">
      <param name="Port" value="7776"/>
   </plugin>

   <plugin name="XMLSocketReceiver" class="org.apache.log4j.net.XMLSocketReceiver">
      <param name="Port" value="7777"/>
   </plugin>
   <root>
      <level value="DEBUG"/>
      <appender-ref ref="FILE"/>
   </root>
</log4j:configuration>

Hope this helps


Scott 


-----Original Message-----
From: Wilfong, Paul [mailto:paul.wilfong@ngc.com]
Sent: Monday, August 13, 2007 8:30 AM
To: Log4J Users List
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?

Thanks very much for the reply!  But I feel I am being dense about this.

I have a PC, call it PC1, running a Java program using SocketAppender with port 7776.  At the same time, PC1 is also running a C++ program using an XMLSocketAppender with port 7777.

Now I have a second PC, call it PC2.  I am looking at your reply to Claudia from long ago:  "While you would have two receivers in your config file, it should work (all of the received events - from either receiver - will be handed over to the RollingFileAppender.)"

This is exactly what I would like to do, but I don't know what you mean by "two receivers in your config file".  Don't I need to write a program for PC2, analogous to the SocketServer program, that listens to 7776 for the PC1 Java program, and 7777 for the PC1 C++ program with XML, and uses a config file with the RollingFileAppender specified?

The "two receivers in your config file" is what throws me.  Does it mean there might be a way to set up PC2 without having to write a new SocketServer-like program?  If so, that would be really great.

Thanks for any help.


-----Original Message-----
From: Scott Deboy [mailto:sdeboy@comotivsystems.com]
Sent: Thursday, August 09, 2007 5:16 PM
To: Log4J Users List
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?

XMLSocketReceiver was written to allow other frameworks (log4cxx, log4php, log4perl, java.util.logging) to send events to log4j over TCP - we already had that ability with SocketAppender/SocketReceiver, so we didn't see a need to write XMLSocketAppender.

Scott Deboy


-----Original Message-----
From: Wilfong, Paul [mailto:paul.wilfong@ngc.com]
Sent: Thursday, August 09, 2007 2:27 PM
To: log4j-user@logging.apache.org
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?


I was wondering if this forum post was ever resolved.  If so, would it be possible for the final config files to be posted?  If not, could an overview of the difficulties be provided?

The original issue was to have both Java and C programs logging, using log4j and log4cxx respectively.  The Java program would use SocketAppender, and the C program XMLSocketAppender.  Then, on another machine, SocketReceiver and XMLSocketReceiver would be used, both with RollingFileAppender.

If I have this right, would a Java program need to be written to execute the SocketReceiver and XMLSocketReceiver logic?

Thanks for any help.

______________________________________________________________________________________________________


Hi Claudia,

I'd suggest using SocketAppender and adding a second receiver to your config file (SocketReceiver).

While you would have two receivers in your config file, it should work (all of the received events - from either receiver - will be handed over to the RollingFileAppender.)

Scott

-----Original Message-----
From: Clᵤia Miazaki [mailto:cmiazaki@itautec-philco.com.br]
Sent: Wednesday, June 30, 2004 6:06 AM
To: 'Log4J Users List'
Cc: cmiazaki@itautec.com.br
Subject: Where is XMLSocketAppender for XMLSocketReceiver?


Hi,

I have tried Scott's suggestion and the combination of log4cxx's XMLSocketAppender sending
logging events to log4j's XMLSocketReceiver did work but I wonder which appenders should be
used if I wanted to log from log4j itself to a XMLSocketReceiver: I could not find XMLSocketAppender
defined in log4j-1.3alpha.

The issue is that I wanted to use the same XML configuration file for both
C++ and Java apps, all of them sending logging events to the same
XMLSocketReceiver, who will later use a RollingFileAppender.

Regards,
Claudia


-----Mensagem original-----
De: Clᵤia Miazaki [mailto:cmiazaki@itautec-philco.com.br]
Enviada em: sexta-feira, 25 de junho de 2004 15:29
Para: 'Scott Deboy'; 'Log4J Users List'
Cc: cmiazaki@itautec.com.br
Assunto: RES: Log4j SocketServer with Log4cxx SockeAppender


Hi,

Sorry to bother again, but I am a newbie to all this logging and XML as well.

I must be missing something (or maybe many things) because I can't make it work yet. Now I
am using log4j v1.3-alpha from CVS and I did this sequence:

(Step 1) Activation of log4j's SimpleSocketServer with this command:
     java org.apache.log4j.net.SimpleSocketServer 12345 siaclog_server.xml where file "siaclog_server.xml"
is attached bellow and port 12345 is not being used in my machine. The last messages shown
at this point inform:
     INFO - Listening on port 12345
     INFO - Listening on port 12345
     INFO - Waiting to accept a new client
     INFO - Waiting to accept a new client
and then it "hangs" waiting for incoming logging events.

(Step 2) Start-up the C++ application linked to log4cxx.dll (version 0.9.7). This application
parses an XML configuration file called "siaclog_client.xml" (also attached) using DOMConfigurator.

At this point these errors occur at the SimpleSocketServer: ERROR - Exception opening ObjectInputStream
to Socket[addr=/127.0.0.1,port=4845,localport=12345]
java.io.StreamCorruptedException: invalid stream header
        at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
        ...


Another question:
As will also have Java applications sending logging events to this same SimpleSocketServer,
which king of appender should them use? I could not find any XMLSocketAppender at log4j.


Best regards

Claudia Miazaki


-----Mensagem original-----
De: Scott Deboy [mailto:sdeboy@comotivsystems.com]
Enviada em: quarta-feira, 23 de junho de 2004 11:29
Para: Log4J Users List; cmiazaki@itautec-philco.com.br
Assunto: RE: Log4j SocketServer with Log4cxx SockeAppender


(requires the latest version of log4j available from CVS):

On the log4j side, use a simplesocketserver, specifying whichever port you want to receive
java events on, and a log4j config file which includes this receiver plugin definition (or
it's properties-style equivalent):

   <plugin name="Log4JXMLSocketReceiver" class="org.apache.log4j.net.XMLSocketReceiver">
     <param name="Port" value="4447"/>
   </plugin>

You can also configure Chainsaw v2 to use the same receiver and view events in the UI.

Scott

-----Original Message-----
From: Clᵤia Miazaki [mailto:cmiazaki@itautec-philco.com.br]
Sent: Wednesday, June 23, 2004 5:14 AM
To: log4j-user@logging.apache.org
Cc: cmiazaki@itautec.com.br
Subject: Log4j SocketServer with Log4cxx SockeAppender


Hi,

I'm trying to use log4j's SocketServer.java on a listening port to manage logging events coming
 both from Java and C++ applications, using log4j and log4cxx SocketAppenders, respectively.
The SocketServer manages logging events from my Java applications fine, but when it receives
logging events from the C++ applications it gets the following exception:

java.io.StreamCorruptedException: invalid stream header
        at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
        ...

Is this kind of usage impossible? Log4j's SocketServer can only deal with logging events from
other Java apps?

Thanks for any help!

Best regards,

Claudia Miazaki


RE: Where is XMLSocketAppender for XMLSocketReceiver?

Posted by Scott Deboy <sd...@comotivsystems.com>.
You don't need to write a program for PC2 - any app that loads a log4j configuration file will do - as long as that configuration file contains both the receivers and appenders you need.

This means you can start SimpleSocketServer on PC2 configured with a log4j configuration file which contains two receiver entries and one appender entry.

The receivers will start receiving the events once configuration is complete - the appender will append any events received by the receivers.

Here's an example log4j config file you could use with the SimpleSocketServer (I know SimpleSocketServer has built-in support for listening on a socket - same as SocketReceiver, you could use that if you want instead of adding the socketreceiver section below - otherwise, make sure that's using a different port!):

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration >
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="true">
<appender name="FILE" class="org.apache.log4j.FileAppender">
	<param name="Append" value="false"/>
	<param name="File" value="log.txt"/>
	<layout class="org.apache.log4j.PatternLayout">
		<param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
	</layout>
</appender>   
   
   <plugin name="SocketReceiver" class="org.apache.log4j.net.SocketReceiver">
      <param name="Port" value="7776"/>
   </plugin>

   <plugin name="XMLSocketReceiver" class="org.apache.log4j.net.XMLSocketReceiver">
      <param name="Port" value="7777"/>
   </plugin>
   <root>
      <level value="DEBUG"/>
      <appender-ref ref="FILE"/>
   </root>
</log4j:configuration>

Hope this helps


Scott 


-----Original Message-----
From: Wilfong, Paul [mailto:paul.wilfong@ngc.com] 
Sent: Monday, August 13, 2007 8:30 AM
To: Log4J Users List
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?

Thanks very much for the reply!  But I feel I am being dense about this.

I have a PC, call it PC1, running a Java program using SocketAppender with port 7776.  At the same time, PC1 is also running a C++ program using an XMLSocketAppender with port 7777.

Now I have a second PC, call it PC2.  I am looking at your reply to Claudia from long ago:  "While you would have two receivers in your config file, it should work (all of the received events - from either receiver - will be handed over to the RollingFileAppender.)"

This is exactly what I would like to do, but I don't know what you mean by "two receivers in your config file".  Don't I need to write a program for PC2, analogous to the SocketServer program, that listens to 7776 for the PC1 Java program, and 7777 for the PC1 C++ program with XML, and uses a config file with the RollingFileAppender specified?

The "two receivers in your config file" is what throws me.  Does it mean there might be a way to set up PC2 without having to write a new SocketServer-like program?  If so, that would be really great.

Thanks for any help.


-----Original Message-----
From: Scott Deboy [mailto:sdeboy@comotivsystems.com] 
Sent: Thursday, August 09, 2007 5:16 PM
To: Log4J Users List
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?

XMLSocketReceiver was written to allow other frameworks (log4cxx, log4php, log4perl, java.util.logging) to send events to log4j over TCP - we already had that ability with SocketAppender/SocketReceiver, so we didn't see a need to write XMLSocketAppender.

Scott Deboy


-----Original Message-----
From: Wilfong, Paul [mailto:paul.wilfong@ngc.com]
Sent: Thursday, August 09, 2007 2:27 PM
To: log4j-user@logging.apache.org
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?


I was wondering if this forum post was ever resolved.  If so, would it be possible for the final config files to be posted?  If not, could an overview of the difficulties be provided?

The original issue was to have both Java and C programs logging, using log4j and log4cxx respectively.  The Java program would use SocketAppender, and the C program XMLSocketAppender.  Then, on another machine, SocketReceiver and XMLSocketReceiver would be used, both with RollingFileAppender.

If I have this right, would a Java program need to be written to execute the SocketReceiver and XMLSocketReceiver logic?

Thanks for any help.

______________________________________________________________________________________________________


Hi Claudia,

I'd suggest using SocketAppender and adding a second receiver to your config file (SocketReceiver).

While you would have two receivers in your config file, it should work (all of the received
events - from either receiver - will be handed over to the RollingFileAppender.)

Scott

-----Original Message-----
From: Clᵤia Miazaki [mailto:cmiazaki@itautec-philco.com.br] 
Sent: Wednesday, June 30, 2004 6:06 AM
To: 'Log4J Users List'
Cc: cmiazaki@itautec.com.br
Subject: Where is XMLSocketAppender for XMLSocketReceiver?


Hi,

I have tried Scott's suggestion and the combination of log4cxx's XMLSocketAppender sending
logging events to log4j's XMLSocketReceiver did work but I wonder which appenders should be
used if I wanted to log from log4j itself to a XMLSocketReceiver: I could not find XMLSocketAppender
defined in log4j-1.3alpha.

The issue is that I wanted to use the same XML configuration file for both
C++ and Java apps, all of them sending logging events to the same
XMLSocketReceiver, who will later use a RollingFileAppender.

Regards,
Claudia


-----Mensagem original-----
De: Clᵤia Miazaki [mailto:cmiazaki@itautec-philco.com.br]
Enviada em: sexta-feira, 25 de junho de 2004 15:29
Para: 'Scott Deboy'; 'Log4J Users List'
Cc: cmiazaki@itautec.com.br
Assunto: RES: Log4j SocketServer with Log4cxx SockeAppender


Hi,

Sorry to bother again, but I am a newbie to all this logging and XML as well.

I must be missing something (or maybe many things) because I can't make it work yet. Now I
am using log4j v1.3-alpha from CVS and I did this sequence:

(Step 1) Activation of log4j's SimpleSocketServer with this command:
     java org.apache.log4j.net.SimpleSocketServer 12345 siaclog_server.xml where file "siaclog_server.xml"
is attached bellow and port 12345 is not being used in my machine. The last messages shown
at this point inform:
     INFO - Listening on port 12345
     INFO - Listening on port 12345
     INFO - Waiting to accept a new client
     INFO - Waiting to accept a new client
and then it "hangs" waiting for incoming logging events.

(Step 2) Start-up the C++ application linked to log4cxx.dll (version 0.9.7). This application
parses an XML configuration file called "siaclog_client.xml" (also attached) using DOMConfigurator.

At this point these errors occur at the SimpleSocketServer: ERROR - Exception opening ObjectInputStream
to Socket[addr=/127.0.0.1,port=4845,localport=12345]
java.io.StreamCorruptedException: invalid stream header
        at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
        ...


Another question:
As will also have Java applications sending logging events to this same SimpleSocketServer,
which king of appender should them use? I could not find any XMLSocketAppender at log4j.


Best regards

Claudia Miazaki


-----Mensagem original-----
De: Scott Deboy [mailto:sdeboy@comotivsystems.com]
Enviada em: quarta-feira, 23 de junho de 2004 11:29
Para: Log4J Users List; cmiazaki@itautec-philco.com.br
Assunto: RE: Log4j SocketServer with Log4cxx SockeAppender


(requires the latest version of log4j available from CVS):

On the log4j side, use a simplesocketserver, specifying whichever port you want to receive
java events on, and a log4j config file which includes this receiver plugin definition (or
it's properties-style equivalent):

   <plugin name="Log4JXMLSocketReceiver" class="org.apache.log4j.net.XMLSocketReceiver">
     <param name="Port" value="4447"/>
   </plugin>

You can also configure Chainsaw v2 to use the same receiver and view events in the UI.

Scott

-----Original Message-----
From: Clᵤia Miazaki [mailto:cmiazaki@itautec-philco.com.br]
Sent: Wednesday, June 23, 2004 5:14 AM
To: log4j-user@logging.apache.org
Cc: cmiazaki@itautec.com.br
Subject: Log4j SocketServer with Log4cxx SockeAppender


Hi,

I'm trying to use log4j's SocketServer.java on a listening port to manage logging events coming
 both from Java and C++ applications, using log4j and log4cxx SocketAppenders, respectively.
The SocketServer manages logging events from my Java applications fine, but when it receives
logging events from the C++ applications it gets the following exception:

java.io.StreamCorruptedException: invalid stream header
        at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
        ...

Is this kind of usage impossible? Log4j's SocketServer can only deal with logging events from
other Java apps?

Thanks for any help!

Best regards,

Claudia Miazaki


RE: Where is XMLSocketAppender for XMLSocketReceiver?

Posted by "Wilfong, Paul" <pa...@ngc.com>.
Thanks very much for the reply!  But I feel I am being dense about this.

I have a PC, call it PC1, running a Java program using SocketAppender with port 7776.  At the same time, PC1 is also running a C++ program using an XMLSocketAppender with port 7777.

Now I have a second PC, call it PC2.  I am looking at your reply to Claudia from long ago:  "While you would have two receivers in your config file, it should work (all of the received events - from either receiver - will be handed over to the RollingFileAppender.)"

This is exactly what I would like to do, but I don't know what you mean by "two receivers in your config file".  Don't I need to write a program for PC2, analogous to the SocketServer program, that listens to 7776 for the PC1 Java program, and 7777 for the PC1 C++ program with XML, and uses a config file with the RollingFileAppender specified?

The "two receivers in your config file" is what throws me.  Does it mean there might be a way to set up PC2 without having to write a new SocketServer-like program?  If so, that would be really great.

Thanks for any help.


-----Original Message-----
From: Scott Deboy [mailto:sdeboy@comotivsystems.com] 
Sent: Thursday, August 09, 2007 5:16 PM
To: Log4J Users List
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?

XMLSocketReceiver was written to allow other frameworks (log4cxx, log4php, log4perl, java.util.logging) to send events to log4j over TCP - we already had that ability with SocketAppender/SocketReceiver, so we didn't see a need to write XMLSocketAppender.

Scott Deboy


-----Original Message-----
From: Wilfong, Paul [mailto:paul.wilfong@ngc.com]
Sent: Thursday, August 09, 2007 2:27 PM
To: log4j-user@logging.apache.org
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?


I was wondering if this forum post was ever resolved.  If so, would it be possible for the final config files to be posted?  If not, could an overview of the difficulties be provided?

The original issue was to have both Java and C programs logging, using log4j and log4cxx respectively.  The Java program would use SocketAppender, and the C program XMLSocketAppender.  Then, on another machine, SocketReceiver and XMLSocketReceiver would be used, both with RollingFileAppender.

If I have this right, would a Java program need to be written to execute the SocketReceiver and XMLSocketReceiver logic?

Thanks for any help.

______________________________________________________________________________________________________


Hi Claudia,

I'd suggest using SocketAppender and adding a second receiver to your config file (SocketReceiver).

While you would have two receivers in your config file, it should work (all of the received
events - from either receiver - will be handed over to the RollingFileAppender.)

Scott

-----Original Message-----
From: Clᵤia Miazaki [mailto:cmiazaki@itautec-philco.com.br] 
Sent: Wednesday, June 30, 2004 6:06 AM
To: 'Log4J Users List'
Cc: cmiazaki@itautec.com.br
Subject: Where is XMLSocketAppender for XMLSocketReceiver?


Hi,

I have tried Scott's suggestion and the combination of log4cxx's XMLSocketAppender sending
logging events to log4j's XMLSocketReceiver did work but I wonder which appenders should be
used if I wanted to log from log4j itself to a XMLSocketReceiver: I could not find XMLSocketAppender
defined in log4j-1.3alpha.

The issue is that I wanted to use the same XML configuration file for both
C++ and Java apps, all of them sending logging events to the same
XMLSocketReceiver, who will later use a RollingFileAppender.

Regards,
Claudia


-----Mensagem original-----
De: Clᵤia Miazaki [mailto:cmiazaki@itautec-philco.com.br]
Enviada em: sexta-feira, 25 de junho de 2004 15:29
Para: 'Scott Deboy'; 'Log4J Users List'
Cc: cmiazaki@itautec.com.br
Assunto: RES: Log4j SocketServer with Log4cxx SockeAppender


Hi,

Sorry to bother again, but I am a newbie to all this logging and XML as well.

I must be missing something (or maybe many things) because I can't make it work yet. Now I
am using log4j v1.3-alpha from CVS and I did this sequence:

(Step 1) Activation of log4j's SimpleSocketServer with this command:
     java org.apache.log4j.net.SimpleSocketServer 12345 siaclog_server.xml where file "siaclog_server.xml"
is attached bellow and port 12345 is not being used in my machine. The last messages shown
at this point inform:
     INFO - Listening on port 12345
     INFO - Listening on port 12345
     INFO - Waiting to accept a new client
     INFO - Waiting to accept a new client
and then it "hangs" waiting for incoming logging events.

(Step 2) Start-up the C++ application linked to log4cxx.dll (version 0.9.7). This application
parses an XML configuration file called "siaclog_client.xml" (also attached) using DOMConfigurator.

At this point these errors occur at the SimpleSocketServer: ERROR - Exception opening ObjectInputStream
to Socket[addr=/127.0.0.1,port=4845,localport=12345]
java.io.StreamCorruptedException: invalid stream header
        at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
        ...


Another question:
As will also have Java applications sending logging events to this same SimpleSocketServer,
which king of appender should them use? I could not find any XMLSocketAppender at log4j.


Best regards

Claudia Miazaki


-----Mensagem original-----
De: Scott Deboy [mailto:sdeboy@comotivsystems.com]
Enviada em: quarta-feira, 23 de junho de 2004 11:29
Para: Log4J Users List; cmiazaki@itautec-philco.com.br
Assunto: RE: Log4j SocketServer with Log4cxx SockeAppender


(requires the latest version of log4j available from CVS):

On the log4j side, use a simplesocketserver, specifying whichever port you want to receive
java events on, and a log4j config file which includes this receiver plugin definition (or
it's properties-style equivalent):

   <plugin name="Log4JXMLSocketReceiver" class="org.apache.log4j.net.XMLSocketReceiver">
     <param name="Port" value="4447"/>
   </plugin>

You can also configure Chainsaw v2 to use the same receiver and view events in the UI.

Scott

-----Original Message-----
From: Clᵤia Miazaki [mailto:cmiazaki@itautec-philco.com.br]
Sent: Wednesday, June 23, 2004 5:14 AM
To: log4j-user@logging.apache.org
Cc: cmiazaki@itautec.com.br
Subject: Log4j SocketServer with Log4cxx SockeAppender


Hi,

I'm trying to use log4j's SocketServer.java on a listening port to manage logging events coming
 both from Java and C++ applications, using log4j and log4cxx SocketAppenders, respectively.
The SocketServer manages logging events from my Java applications fine, but when it receives
logging events from the C++ applications it gets the following exception:

java.io.StreamCorruptedException: invalid stream header
        at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
        ...

Is this kind of usage impossible? Log4j's SocketServer can only deal with logging events from
other Java apps?

Thanks for any help!

Best regards,

Claudia Miazaki


RE: Where is XMLSocketAppender for XMLSocketReceiver?

Posted by Scott Deboy <sd...@comotivsystems.com>.
XMLSocketReceiver was written to allow other frameworks (log4cxx, log4php, log4perl, java.util.logging) to send events to log4j over TCP - we already had that ability with SocketAppender/SocketReceiver, so we didn't see a need to write XMLSocketAppender.

Scott Deboy


-----Original Message-----
From: Wilfong, Paul [mailto:paul.wilfong@ngc.com] 
Sent: Thursday, August 09, 2007 2:27 PM
To: log4j-user@logging.apache.org
Subject: RE: Where is XMLSocketAppender for XMLSocketReceiver?


I was wondering if this forum post was ever resolved.  If so, would it be possible for the final config files to be posted?  If not, could an overview of the difficulties be provided?

The original issue was to have both Java and C programs logging, using log4j and log4cxx respectively.  The Java program would use SocketAppender, and the C program XMLSocketAppender.  Then, on another machine, SocketReceiver and XMLSocketReceiver would be used, both with RollingFileAppender.

If I have this right, would a Java program need to be written to execute the SocketReceiver and XMLSocketReceiver logic?

Thanks for any help.

______________________________________________________________________________________________________


Hi Claudia,

I'd suggest using SocketAppender and adding a second receiver to your config file (SocketReceiver).

While you would have two receivers in your config file, it should work (all of the received
events - from either receiver - will be handed over to the RollingFileAppender.)

Scott

-----Original Message-----
From: Clᵤia Miazaki [mailto:cmiazaki@itautec-philco.com.br] 
Sent: Wednesday, June 30, 2004 6:06 AM
To: 'Log4J Users List'
Cc: cmiazaki@itautec.com.br
Subject: Where is XMLSocketAppender for XMLSocketReceiver?


Hi,

I have tried Scott's suggestion and the combination of log4cxx's XMLSocketAppender sending
logging events to log4j's XMLSocketReceiver did work but I wonder which appenders should be
used if I wanted to log from log4j itself to a XMLSocketReceiver: I could not find XMLSocketAppender
defined in log4j-1.3alpha.

The issue is that I wanted to use the same XML configuration file for both
C++ and Java apps, all of them sending logging events to the same
XMLSocketReceiver, who will later use a RollingFileAppender.

Regards,
Claudia


-----Mensagem original-----
De: Clᵤia Miazaki [mailto:cmiazaki@itautec-philco.com.br]
Enviada em: sexta-feira, 25 de junho de 2004 15:29
Para: 'Scott Deboy'; 'Log4J Users List'
Cc: cmiazaki@itautec.com.br
Assunto: RES: Log4j SocketServer with Log4cxx SockeAppender


Hi,

Sorry to bother again, but I am a newbie to all this logging and XML as well.

I must be missing something (or maybe many things) because I can't make it work yet. Now I
am using log4j v1.3-alpha from CVS and I did this sequence:

(Step 1) Activation of log4j's SimpleSocketServer with this command:
     java org.apache.log4j.net.SimpleSocketServer 12345 siaclog_server.xml where file "siaclog_server.xml"
is attached bellow and port 12345 is not being used in my machine. The last messages shown
at this point inform:
     INFO - Listening on port 12345
     INFO - Listening on port 12345
     INFO - Waiting to accept a new client
     INFO - Waiting to accept a new client
and then it "hangs" waiting for incoming logging events.

(Step 2) Start-up the C++ application linked to log4cxx.dll (version 0.9.7). This application
parses an XML configuration file called "siaclog_client.xml" (also attached) using DOMConfigurator.

At this point these errors occur at the SimpleSocketServer: ERROR - Exception opening ObjectInputStream
to Socket[addr=/127.0.0.1,port=4845,localport=12345]
java.io.StreamCorruptedException: invalid stream header
        at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
        ...


Another question:
As will also have Java applications sending logging events to this same SimpleSocketServer,
which king of appender should them use? I could not find any XMLSocketAppender at log4j.


Best regards

Claudia Miazaki


-----Mensagem original-----
De: Scott Deboy [mailto:sdeboy@comotivsystems.com]
Enviada em: quarta-feira, 23 de junho de 2004 11:29
Para: Log4J Users List; cmiazaki@itautec-philco.com.br
Assunto: RE: Log4j SocketServer with Log4cxx SockeAppender


(requires the latest version of log4j available from CVS):

On the log4j side, use a simplesocketserver, specifying whichever port you want to receive
java events on, and a log4j config file which includes this receiver plugin definition (or
it's properties-style equivalent):

   <plugin name="Log4JXMLSocketReceiver" class="org.apache.log4j.net.XMLSocketReceiver">
     <param name="Port" value="4447"/>
   </plugin>

You can also configure Chainsaw v2 to use the same receiver and view events in the UI.

Scott

-----Original Message-----
From: Clᵤia Miazaki [mailto:cmiazaki@itautec-philco.com.br]
Sent: Wednesday, June 23, 2004 5:14 AM
To: log4j-user@logging.apache.org
Cc: cmiazaki@itautec.com.br
Subject: Log4j SocketServer with Log4cxx SockeAppender


Hi,

I'm trying to use log4j's SocketServer.java on a listening port to manage logging events coming
 both from Java and C++ applications, using log4j and log4cxx SocketAppenders, respectively.
The SocketServer manages logging events from my Java applications fine, but when it receives
logging events from the C++ applications it gets the following exception:

java.io.StreamCorruptedException: invalid stream header
        at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
        ...

Is this kind of usage impossible? Log4j's SocketServer can only deal with logging events from
other Java apps?

Thanks for any help!

Best regards,

Claudia Miazaki