Logging from Service

Post questions here regarding the CodeSite Express edition

Logging from Service

Postby ruijs@rvc.nl » Sun Jun 12, 2011 6:52 am

Hi,

I want to use CodeSite version included in XE to log to file from a Service Application. See code below, which works in an app. What am I doing wrong? I verified write persissions, path existence etc.

Also, I want daily logfile creation, I assume that I can upgrade to CodeSite Studio?

Regards, Ronald

---
procedure TRVCListener.ServiceStart(Sender: TService; var Started: Boolean);
var
d: TCodeSiteDestination;
s: string;

begin
s := GetLongFileName(GetModuleName(HInstance));
d := TCodeSiteDestination.Create(Self);

d.LogFile.Active := True;
d.LogFile.FileName := ChangeFileExt(s, '.log');
d.LogFile.FilePath := ExtractFilePath(s);

CodeSite.Destination := d;
// CodeSite.ConnectUsingTcp; <--tried this, did not help
CodeSite.Send('Starting Service');
---
ruijs@rvc.nl
 
Posts: 1
Joined:
Sun Jun 12, 2011 6:46 am

Re: Logging from Service

Postby Raize Support » Sun Jun 12, 2011 4:36 pm

Hi,

There is more information about logging from services in the help file. But in short, because services run in a different window station from the user's desktop, you need to use TCP to send the CodeSite messages from your service to the CodeSite Dispatcher. Therefore, you do need to use the ConnectUsingTcp method. However, I recommend calling

CodeSiteManager.ConnectUsingTcp

at the beginning of your application before you make any CodeSite calls. By calling this method on the CodeSiteManager instance, ALL CodeSite loggers will use TCP to communicate with the Dispatcher.

The second piece is that because the CodeSite messages are transferred as TCP messages, the CodeSite Dispatcher must be monitoring the TCP port those messages are coming in on. Right-click on the CodeSite Dispatcher (you can also do this using the CodeSite Controller), and click on the Ports tab. Be sure that the Monitor Ports check box is checked and that the TCP port is set to the default value of 3434.

And finally, yes it is possible to upgrade to CodeSite Studio from the Express Edition. To do so, simply use our online order center (http://www.raize.com/DevTools/Ordering) and in the Promotion Code field enter "CS4URSXE" and then select the desired product quantities as well as contact and payment information. For each copy of CodeSite Studio selected, you will be charged 299 USD instead of the regular 399 USD price.

Ray


ruijs@rvc.nl wrote:I want to use CodeSite version included in XE to log to file from a Service Application. See code below, which works in an app. What am I doing wrong? I verified write persissions, path existence etc.

Also, I want daily logfile creation, I assume that I can upgrade to CodeSite Studio?

Regards, Ronald

---
procedure TRVCListener.ServiceStart(Sender: TService; var Started: Boolean);
var
d: TCodeSiteDestination;
s: string;

begin
s := GetLongFileName(GetModuleName(HInstance));
d := TCodeSiteDestination.Create(Self);

d.LogFile.Active := True;
d.LogFile.FileName := ChangeFileExt(s, '.log');
d.LogFile.FilePath := ExtractFilePath(s);

CodeSite.Destination := d;
// CodeSite.ConnectUsingTcp; <--tried this, did not help
CodeSite.Send('Starting Service');
---
Raize Software Support
Raize Software
http://www.raize.com
Raize Support
 
Posts: 622
Joined:
Fri Mar 25, 2011 9:04 pm

re:

Postby awainoamora » Mon Jul 04, 2011 1:07 pm

+1
awainoamora
 
Posts: 1
Joined:
Fri May 13, 2011 4:21 pm
Location: Italy


Return to Express Edition

Who is online

Users browsing this forum: No registered users and 1 guest

cron