This project is read-only.
1
Vote

Multiple threads log to multiple log file

description

Hi.

In my application I am creating multiple thread and wants each create it's own log file with thread name.

Example
Thread1.Name="Test1"
Thread2.Name="Test2"

So Thread1 create Test1.log and Thread2.Create Test2.log


Thanks ,

Ranjita

comments

randylevy wrote Aug 7, 2015 at 7:43 AM

The easiest way would be to have each thread perform programmatic configuration when the thread starts and to obtain a LogWriter instance per thread which would then be used to log for that thread (and then dispose the LogWriter when the thread is done).

This discussion has an example which does something similar except it creates a separate file by category: http://entlib.codeplex.com/discussions/450137 . The major difference is that the "category files" are probably longer lived (keep writing for the duration of the application) compared to the "thread files" which I would imagine would be shorter lived (but may not be for a long running thread).