Chaning destination at runtime

Post questions here regarding the CodeSite Express edition

Chaning destination at runtime

Postby patrick » Fri May 20, 2011 6:03 am

Hi

As log files can grow quite large I need to create a new one each day. How do I change the code site destination dynamically? I have tried the following but CodeSite still logs to the original file:

Code: Select all
   
    date_ := formatdatetime('yyyy-mm-dd_hhnnss', now()); //new date determines new log file name
    logPath_ := CodeSite.Destination.LogFile.FilePath;
    CodeSite.Destination.LogFile.Active := false;
    CodeSite.Destination.Free;
    Destination := TCodeSiteDestination.Create(Application);
    Destination.LogFile.Active := True;
    Destination.LogFile.FileName := Format('%s_%s.csl' , [Settings.LoggingConfig.LogFilename, date_]);
    Destination.LogFile.FilePath := logPath_;
    CodeSite.Destination := Destination;

Thanks

- Patrick
patrick
 
Posts: 4
Joined:
Fri May 20, 2011 5:55 am

Re: Chaning destination at runtime

Postby Raize Support » Fri May 20, 2011 11:39 pm

Hi Patrick,

Good catch. The reason the messages are getting logged to the same file is because the hashing code that is used to determine if two destinations are the same is indeed seeing the change in date as being the same log file. We'll be sure to fix this for the next release.

However, you can work around the issue by adding the following statement before you change the destination:


CodeSite.ConnectUsingCopyData;

This will reset the internal connection that is used to communicate with the Dispatcher and also clears the hash table and thus avoids the issue.

Ray
Raize Software Support
Raize Software
http://www.raize.com
Raize Support
 
Posts: 611
Joined:
Fri Mar 25, 2011 9:04 pm

Re: Chaning destination at runtime

Postby patrick » Sat May 21, 2011 9:43 am

Hi Ray

Many thanks for the prompt reply. I'll try your solution when i'm back in the office on Monday.
Cheers

Patrick
patrick
 
Posts: 4
Joined:
Fri May 20, 2011 5:55 am

Re: Chaning destination at runtime

Postby Raize Support » Mon May 23, 2011 12:21 am

Hi Patrick,

I should have also noted that in the Studio Edition, there are two more parameters for the LogFile destination. LogByDate and DateFormat. When LogByDate is set, then the log file is automatically changed when the date changes. The DateFormat value controls how the date is formatted in the file name.

Ray
Raize Software Support
Raize Software
http://www.raize.com
Raize Support
 
Posts: 611
Joined:
Fri Mar 25, 2011 9:04 pm

Re: Chaning destination at runtime

Postby patrick » Mon May 23, 2011 6:14 am

Hi Ray

That sounds useful if we decide to upgrade from the express version. Your earlier suggestion worked which is great.
Many Thanks

Patrick Hemsley
patrick
 
Posts: 4
Joined:
Fri May 20, 2011 5:55 am


Return to Express Edition

Who is online

Users browsing this forum: No registered users and 1 guest

cron