Print Page | Close Window

Changing LogFile at Runtime

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce Classic
Forum Discription: For .NET 2.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1109
Printed Date: 23-Apr-2024 at 3:21am


Topic: Changing LogFile at Runtime
Posted By: ken.nelson
Subject: Changing LogFile at Runtime
Date Posted: 03-Mar-2009 at 10:27am
Is there a way to change the log file path at run time?
 
The application we're writing will be installed on several client machines with very limited write access to the local machine.  The default log file path is the same as the executable path (i.e. C:\Program Files...), but we are not allowed write access to that path.  We can write to the user's My Documents path, but obviously this path is different for every user so we can't simply set a different path in the ideablade.ibconfig file.
 
Using the Object Browser, I was able to find:
 
IdeaBlade.Util.IdeaBladeConfig, and thought that I might be able to use the following to set the log file path:
 
IdeaBlade.Util.IdeaBladeConfig c = IdeaBlade.Util.IdeaBladeConfig.Instance;
c.Logging.LogFile= @"C:\new path\DebugLog.xml";
 
This does update the LogFile, but it doesn't seem to have any effect on where the file is written.  I also noticed that c.Logging has a FullyQualifiedLogFile property that is not being updated when I explicitly set the LogFile, and it is read only so I can't update this manually.
 
Is there anyway to get around this problem?
 
Thanks,
Ken
 



Replies:
Posted By: kimj
Date Posted: 03-Mar-2009 at 3:44pm
Unfortunately there's no way to change the path at runtime, since once you reference IdeaBladeConfig.Instance it’s too late – the configuration information has already loaded and tracing has started.  There is a workaround however; you can create another instance of the logger, like this:

       TraceFileXmlLogger logger = new TraceFileXmlLogger(@"c:\new path\DebugLog.xml", true);

Note that initialization activities prior to creation of this instance won’t be logged to this file.  You can also set the <logFile> element in your ibconfig to an empty string if you don’t want multiple log files although you may miss important startup messages.  Note that here in IdeaBlade support we usually want a full debug log when diagnosing problems.

 



Posted By: ken.nelson
Date Posted: 05-Mar-2009 at 12:16pm
Excellent.  Thanks, that works for us.



Print Page | Close Window