separate loggers, different content

CodeSite logging interface classes: default "CodeSite" logger, T|CodeSiteLogger class, destinations, formatters, etc.

separate loggers, different content

Postby wmeyer » Tue Jun 19, 2012 7:35 am

I have been trying to set up a separate logger to output to a file. I do not want the messages I see in the viewer to be in the file, I want only those messages which I send to the separate logger. So far, I get everything in both. How can I achieve the separate content I need?
wmeyer
 
Posts: 3
Joined:
Mon Jun 18, 2012 8:51 pm

Re: separate loggers, different content

Postby Raize Support » Tue Jun 19, 2012 12:14 pm

Hi,

The key is to setup a different Destination for each logger. To do this, you need to create the appropriate CodeSiteDestination object and assign it to the appropriate logger's Destination property and NOT assign it to the CodeSiteManager.DefaultDestination property.

So for example, suppose you want to use the default CodeSite logger to send messages to the Live Viewer, and you create a new logger, csAuditLog, where you want to send to a log file. When you create the csAuditLog logger, you can do the following:

Code: Select all
csAuditLog := TCodeSiteLogger.Create( Self );

Dest := TCodeSiteDestination.Create( Self );
Dest.LogFile.Active := True;
Dest.LogFile.FilePath := 'C:\Logs';
Dest.LogFile.FileName := 'AuditLog.csl';

csAuditLog.Destination := Dest;


With the above code, only the csAuditLog logger will use the log file destination. The default CodeSite logger, and any other loggers, will use the default destination defined in the CodeSiteManager, which defaults to the Live Viewer.

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

Re: separate loggers, different content

Postby wmeyer » Tue Jun 19, 2012 4:14 pm

Hi Ray,

The actual code I used was:

Code: Select all
  CodeSiteLog := TCodeSiteLogger.Create( Self );
  LogDest := TCodeSiteDestination.Create( Self );
  LogDest.LogFile.Active := True;
  LogDest.LogFile.FileName := 'StudentImportLog.csl';
  LogDest.LogFile.FilePath := '$(MyDocs)';

  CodeSiteLog.Destination := LogDest;


The result was that my log file contained not only what I sent, but what was sent to the viewer, as well. Apart from names and paths, I do not see how mine is different to what you posted.

Bill
wmeyer
 
Posts: 3
Joined:
Mon Jun 18, 2012 8:51 pm

Re: separate loggers, different content

Postby Raize Support » Tue Jun 19, 2012 10:22 pm

Hi Bill,

Can you recreate the problem in a test project? If so, please send the source code (no executables) to support@raize.com and I'll take a look. I suspect there is something else going on in your code that is not shown in your code segment. For example, what is the other logger that you are using to send messages to the Live Viewer?

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

Re: separate loggers, different content

Postby wmeyer » Wed Jun 20, 2012 5:45 am

Hi Ray,

I will try to create a small project which replicates the behavior. As far as I know, the rest of the project is using the default logger. I was surprised to see both streams in the logger I had created, as I had simply followed your example in the help file. (Yes, I am one of those odd folks who reads documentation.)

Thanks,

Bill
wmeyer
 
Posts: 3
Joined:
Mon Jun 18, 2012 8:51 pm


Return to Loggers

Who is online

Users browsing this forum: No registered users and 1 guest

cron