Programmatically use Logging block with no App.Config File?

Topics: Logging Application Block
Feb 16, 2009 at 9:38 PM
Edited Feb 16, 2009 at 9:38 PM
I am using the MSMQDistributorService to log messages to multiple config files. The problem with that is the messages I am logging are not going to the correct file everytime. The reason for this is that I am changing the filename for every logentry received from the queue. There is a slight delay when saving the new filename to the "app.config" and so the messages go to the incorrect log file. I only just found this out while test the MSMQDistibutorService with alot of messages from the queue. Any suggestions on how to programmatically use the logging block with no app.config? I believe this will solve my problem. Let me know if you want any code examples of what I have done.

Here is the thread where I got the code used to set the values in the app.config: http://www.codeplex.com/entlib/Thread/View.aspx?ThreadId=42345
Thanks in advance,
Josh


Feb 17, 2009 at 3:14 AM
Try first if changing the defaultpollingtime will address your issue on the delay changes (see http://www.codeplex.com/entlib/Thread/View.aspx?ThreadId=16623).  If not, refer to this blog by David Hayden - http://davidhayden.com/blog/dave/archive/2006/02/18/2805.aspx


Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com
 
Feb 17, 2009 at 4:34 AM
I will definitely try the defaultpollingtime change. Thanks Sarah! As for the post on David Hayden blog, I have already tried that and it did not work. I was wondering if there is a way to set the file location through an extension to the Write method in the LogWriter.cs class?
Feb 17, 2009 at 5:37 AM
I don't think that would work since filename associated to a tracelistener are being initialized in the constructor.  And entlib tracelisteners are created based on the configuration file where you configure the file name.  If changing the defaultpollingtime doesn't work, could you tell me in what way did David Hayden's blog didn't work?


Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com