Using 2 Listeners in my application

Topics: Logging Application Block
Feb 4, 2008 at 3:04 AM
Hello Experts,
I am trying to use Logging Application Block so that I can log messages to a flat file and after save to a database.

Here's my situation.
o By default any messages will be logged to a flat file.
o When the user closes the application, any logged messages from a flat file will be saved to database using a database trace listener

So what I did, I tried to create 2 separate application
o one that uses FlatFileTraceListener - successful, I can log any messages to trace.log or any flat file
o one that uses FormattedDatabaseTraceListener - successful, I can log any messages to my Logging Database

Problem:
o Since I tested this 2 trace listener and I was able to create an application separately, I just want to know how to combine this 2 trace listener in a single application. For example in my configuration file I have this 2 trace listeners so that by default my application use Flat File Trace Listener and log any messages to a flat file and after that when the user closes the application I can now transfer all LogEntry from a flat file source to database. Or in any scenario, I just want to know how easily to switch from one listener to another listener.

Thank you so much
gneiss01