Using the same log file from two different .net applications

Topics: Logging Application Block
Jun 16, 2008 at 8:45 AM

Hi ,

How can we log to a same log file from two different .Net applications (assume console application and windows service application).

we are using enterprise library 3.1 for logging.

We tried passing the log file path from the console application to the service on start event as one of the arguments to the service. Since the log file is opened by console application and when the service application tries to log information, a new file with the guid is created.

Thanks

 

Jun 16, 2008 at 3:09 PM

Hi,

There is no support for sharing a trace listener in the built in trace listeners, not even from the same application. This behavior is defined by the .NET Framework's TextWriterTraceListener: "If an attempt is made to write to a file that is in use or unavailable, the file name is automatically prefixed by a GUID."

Fernando


prapro wrote:

Hi ,

How can we log to a same log file from two different .Net applications (assume console application and windows service application).

we are using enterprise library 3.1 for logging.

We tried passing the log file path from the console application to the service on start event as one of the arguments to the service. Since the log file is opened by console application and when the service application tries to log information, a new file with the guid is created.

Thanks

 




Jun 17, 2008 at 5:06 AM
Fsimonazzi,

Thanks for your comments.  What could be other alternatives to use the same log file across applications.


Thanks




Jun 17, 2008 at 12:03 PM
Hi,

You can either define your own trace listener that doesn't keep the file open, or use the distributor service and write to the file in a single place; for the latter you'll need to set up MSMQ.

Hope this helps,
Fernando


prapro wrote:
Fsimonazzi,

Thanks for your comments.  What could be other alternatives to use the same log file across applications.


Thanks