Flat file listener from different processes

Topics: Logging Application Block
Apr 24, 2007 at 6:12 AM

we are currently facing an issue with using the flat file listener from different processes using the same logfile name in the configuration. Since the flat file listener is derived from System.Diagnostics.TextWriterTraceListener, the logfile of the 'second'process will get prefixed with a GUID, since the listener tries to exclusively open the logfile. Is there any workaround or implementation or idea, how to be able to log into the same file from different processes

Best regards
Apr 24, 2007 at 1:43 PM

I would check the documentation on the Distributor Service which is located in the help file under Logging Application Block -> Developing Using the Logging Application Block -> Using the Distributor Service .

I have never used it, but it sounds exactly for this type of scenario. Per the documentation:

"Applications must often send log entries from multiple sources to a common destination. The Logging Application Block takes advantage of Windows Message Queuing (also known as MSMQ) to allow you to do this. By configuring multiple applications to use the same message queue, you can process log entries at a central location.

To distribute log entries to a central destination, configure your application to write log entries to the Message Queuing trace listener. When the application sends a log entry to the Logging Application Block, it places the log entry on a Message Queuing queue. The distributor service runs as a Windows service on either the same computer as the application or on a remote computer. It polls the queue to see if there are any log entries on it. The polling interval is determined by configuration.

If there are log entries on the queue, the distributor service uses an instance of the Logging Application Block to forward the messages to the trace listener(s). The trace listener(s) write the log entries to the destinations, such as an event log or a flat file."

There may be other options.




David Hayden
Microsoft MVP C#