You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-user@logging.apache.org by Mike SG <mi...@yahoo.com> on 2004/09/10 22:46:21 UTC

Question regarding FileAppender...

Hi,

I compiled successfully the log4cxx on solaris and I am trying to run a small example which uses FileAppender. Our project is a multi process system. So I created a small example which has 2 processes writing to a file. I used the FileAppender for this. But when I see the output I see that it not process safe. The output is mixed up. Does this works only for threads in a single application. 

Have I done something wrong? Can I use fileappender in a multiprocess application? Do I need to set something?

What options do I have?

Can somebody please help me on this.

Thanks a lot,

-Mike.



		
---------------------------------
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.

Re: Question regarding FileAppender...

Posted by Mike SG <mi...@yahoo.com>.
Renny & Christophe,
 
Thanks for the information. 
 
-Mike

Christophe de VIENNE <cd...@alphacent.com> wrote:
Mike SG wrote:

> Have I done something wrong? Can I use fileappender in a multiprocess 
> application? Do I need to set something?
>
> What options do I have?
>
The simplest option you have is to use simplesocketserver from the
package. In your application send all the logs to a socket appender
which send you log events to a simple server, which itself send
everything to FileAppender.
The final output should be the one you expect.

Regards,

Christophe



		
---------------------------------
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!

Re: Question regarding FileAppender...

Posted by Christophe de VIENNE <cd...@alphacent.com>.
Mike SG wrote:

> Have I done something wrong? Can I use fileappender in a multiprocess 
> application? Do I need to set something?
>
> What options do I have?
>
The simplest option you have is to use simplesocketserver from the
package. In your application send all the logs to a socket appender
which send you log events to a simple server, which itself send
everything to FileAppender.
The final output should be the one you expect.

Regards,

Christophe



Re: Question regarding FileAppender...

Posted by Mike SG <mi...@yahoo.com>.
Thanks Arnold for the information.
 
-Mike.

Curt Arnold <ca...@apache.org> wrote:
log4cxx follows log4j and log4j does not attempt to synchronize file 
I/O across multiple processes. This is addressed in Chapter 10 of "The 
complete manual log4j".

Q 10.3 Can multiple Java Virtual Machines log to the same file using 
log4j?

No, there is no way for log4j to coordinate the access for a system 
resource, for example a file, between multiple JVMs....

The following FAQ describes the common method of addressing situations 
where that is necessary by using SocketAppenders and a daemon that 
receives the log requests and writes to a file: 
http://logging.apache.org/log4j/docs/faq.html#3.3


On Sep 10, 2004, at 3:46 PM, Mike SG wrote:

> Hi,
>
> I compiled successfully the log4cxx on solaris and I am trying to run 
> a small example which uses FileAppender. Our project is a multi 
> process system. So I created a small example which has 2 processes 
> writing to a file. I used the FileAppender for this. But when I see 
> the output I see that it not process safe. The output is mixed up. 
> Does this works only for threads in a single application.
>
> Have I done something wrong? Can I use fileappender in a multiprocess 
> application? Do I need to set something?
>
> What options do I have?
>
> Can somebody please help me on this.
>
> Thanks a lot,
>
> -Mike.
>
> Do you Yahoo!?
> Yahoo! Mail Address AutoComplete - You start. We finish.

		
---------------------------------
Do you Yahoo!?
Express yourself with Y! Messenger! Free. Download now.

Re: Question regarding FileAppender...

Posted by Curt Arnold <ca...@apache.org>.
log4cxx follows log4j and log4j does not attempt to synchronize file 
I/O across multiple processes.  This is addressed in Chapter 10 of "The 
complete manual log4j".

Q 10.3 Can multiple Java Virtual Machines log to the same file using 
log4j?

No, there is no way for log4j to coordinate the access for a system 
resource, for example a file, between multiple JVMs....

The following FAQ describes the common method of addressing situations 
where that is necessary by using SocketAppenders and a daemon that 
receives the log requests and writes to a file: 
http://logging.apache.org/log4j/docs/faq.html#3.3


On Sep 10, 2004, at 3:46 PM, Mike SG wrote:

> Hi,
>
> I compiled successfully the log4cxx on solaris and I am trying to run 
> a small example which uses FileAppender. Our project is a multi 
> process system. So I created a small example which has 2 processes 
> writing to a file. I used the FileAppender for this. But when I see 
> the output I see that it not process safe. The output is mixed up. 
> Does this works only for threads in a single application.
>
>  Have I done something wrong? Can I use fileappender in a multiprocess 
> application? Do I need to set something?
>
> What options do I have?
>
> Can somebody please help me on this.
>
> Thanks a lot,
>
> -Mike.
>
> Do you Yahoo!?
> Yahoo! Mail Address AutoComplete - You start. We finish.