BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Logging components?
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Thirdparty Tools (General)
View previous topic :: View next topic  
Author Message
Lauchlan M
Guest





PostPosted: Tue May 17, 2005 1:52 am    Post subject: Logging components? Reply with quote



It's simple enough to do anyway, but out of interest:

What logging components are there out there?

Do people use them?

What advantages do they offer?

Which ones do you use?

Basically I mean something that would take a handled exception and log
whatever details you give it to file. Normally I'd just log to a text file,
but if I used a logging component I guess it would be better if it gave me
options, eg to text file, XML, binary, database, etc.

It should do all the obvious and normal things, eg record the error
name/category and details I pass to it, attach a timestamp, attach a userID
if appropriate, etc.

If it were reasonably clever, it would have logic to allow you to configure
whether to record every error, or just the first instance of each (perhaps
with a running total of how many times and how frequently it has been
occuring).

Or maybe everyone's logging requirements are individual/specific anyway, so
everyone just rolls their own.

By logging components, I specifically DON'T MEAN components for catching
UNHANDLED exceptions like MadExcept, EurekaLog, etc. I'm interested in what
you do (or don't) use to log HANDLED exceptions and errors.

Thanks

Lauchlan M


Back to top
Danijel Tkalcec
Guest





PostPosted: Tue May 17, 2005 5:59 am    Post subject: Re: Logging components? Reply with quote



I think Logging is pretty much individual, so that usualy everyone has their
own version.
I've used different versions of log units over the past years, most of them
simply for writing into a textfile.
For logging database actions, it depends on the database structure and
things you want to log (also, where you want to log them).

I think its best to log everything you think is worth logging,
then have a separate program to summarize this information on stuff you feel
like summarizing.

Here is the log-writing unit I use for most apps today.
It is simple to use, thread-safe and there are no special preparations
needed
(call "StartLog" to enable, "StopLog" to disable logging and "Log"/"XLog" to
add to the log).
You could create a class from this, but it's easier to use as set of
procedures.
----------------------------------------
{
@html()
Log File Creation
@html(
)
- Copyright (c) Danijel Tkalcec
@html(

)

This unit gives you thread-safe Log writing support.
}
unit rtcLog;

interface

uses
SysUtils, SyncObjs, Windows;

var
{ Write Logged exception into the Log file?
Dafault=True. By changing this to False will remove any
Connection component exceptions from the Log file. }
LOG_EXCEPTIONS:boolean=True;

{ Write exception with a short string description into the Global App Log
file.
This procedure will have no effect if Log writer not started
(by calling StartLog) or LOG_EXCEPTIONS is @false }
procedure Log(s:string; E:Exception; const name:string=''); overload;

{ Write message into the Global App Log file.
This procedure will have no effect if Log writer not started. }
procedure Log(s:string; const name:string=''); overload;

{ Write message into the Log file for the current date.
This procedure will have no effect if Log writer not started. }
procedure XLog(s:string; const name:string=''); overload;

{ Before Log() procedures will have any effect,
you have to call this procedure to start the Log writer.
Without it, no Log file. }
procedure StartLog;

{ To stop Log file creation, simply call this procedure.
To continue log writing, call StartLog. }
procedure StopLog;

implementation

var
ThrCS:TCriticalSection;
doLog:boolean=False;

procedure StartLog;
begin
ThrCS.Enter;
try
doLog:=True;
finally
ThrCS.Leave;
end;
end;

procedure StopLog;
begin
ThrCS.Enter;
try
doLog:=False;
finally
ThrCS.Leave;
end;
end;

procedure XLog(s:string; const name:string='');
var
f:TextFile;
d:TDateTime;
fname,
s2:string;
begin
ThrCS.Enter;
try
if not doLog then Exit; // Exit here !!!!

try
d:=Now;
s2:=FormatDateTime('[yyyy-mm-dd hh:nn:ss] ',d);

if name<>'' then
fname:=ParamStr(0)+'.'+FormatDateTime('yyyy_mm_dd',d)+'.'+name+'.log'
else
fname:=ParamStr(0)+'.'+FormatDateTime('yyyy_mm_dd',d)+'.log';

Assign(f,fname);
{$I-}
Append(f);
{$I+}
if IOREsult<>0 then
Rewrite(f);
try
Writeln(f,s2+s);
finally
CloseFile(f);
end;
except
end;

finally
ThrCS.Leave;
end;
end;

procedure Log(s:string; const name:string='');
var
f:TextFile;
d:TDateTime;
fname,
s2:string;
begin
ThrCS.Enter;
try
if not doLog then Exit; // Exit here !!!!

try
d:=Now;
s2:=FormatDateTime('[yyyy-mm-dd hh:nn:ss] ',d);
if name<>'' then
fname:=ParamStr(0)+'.'+name+'.log'
else
fname:=ParamStr(0)+'.log';

Assign(f,fname);
{$I-}
Append(f);
{$I+}
if IOREsult<>0 then
Rewrite(f);
try
Writeln(f,s2+s);
finally
CloseFile(f);
end;
except
end;

finally
ThrCS.Leave;
end;
end;

procedure Log(s:string; E:Exception; const name:string='');
begin
if LOG_EXCEPTIONS then
Log(s+' Exception! '+E.ClassName+': '+E.Message, name);
end;

initialization
ThrCS:=TCriticalSection.Create;
finalization
ThrCS.Free;
end.
-----------------------------------------

This unit is part of RealThinClient component package:
www.realthinclient.com

XLog() is for creating daily logs (every day, a new log file), while Log()
is for writing global logs.
By using the "name" parameter, you can use different files for different
parts of your application,
or different kinds of logs: error, warning, information, etc.
This should be simple enough to understand and powerful enough to suit most
apps needs.

Best Regards,
Danijel Tkalcec

"Lauchlan M" <LMackinnonAT_NoSpam_ozemailDOTcomDOTau> wrote

Quote:
It's simple enough to do anyway, but out of interest:

What logging components are there out there?

Do people use them?

What advantages do they offer?

Which ones do you use?

Basically I mean something that would take a handled exception and log
whatever details you give it to file. Normally I'd just log to a text
file,
but if I used a logging component I guess it would be better if it gave me
options, eg to text file, XML, binary, database, etc.

It should do all the obvious and normal things, eg record the error
name/category and details I pass to it, attach a timestamp, attach a
userID
if appropriate, etc.

If it were reasonably clever, it would have logic to allow you to
configure
whether to record every error, or just the first instance of each (perhaps
with a running total of how many times and how frequently it has been
occuring).

Or maybe everyone's logging requirements are individual/specific anyway,
so
everyone just rolls their own.

By logging components, I specifically DON'T MEAN components for catching
UNHANDLED exceptions like MadExcept, EurekaLog, etc. I'm interested in
what
you do (or don't) use to log HANDLED exceptions and errors.

Thanks

Lauchlan M





Back to top
Danijel Tkalcec
Guest





PostPosted: Tue May 17, 2005 6:09 am    Post subject: Re: Logging components? Reply with quote



Anyway .. I think that logging mechanisms should be simple enough
to avoid having to log errors that could happen inside the logging routines.

Things like low memory usage (if possible: no HEAP, only stack memory),
fast entry - fast exit (no long-lasting operations),
and no pre-configuration sound like a "must" for general logging.

If you need to log a lot of database-related things,
which is not threatening your application stability,
you could also add a separate logging mechanism to write
database-related stuff inside one or more tables inside a database.

By separating simple file-logging for errors and dabase-logging for
database-stuff,
you won't end up with an error that causes database-writing to fail and not
knowing what happened.

Regards,
Daijel Tkalcec

"Lauchlan M" <LMackinnonAT_NoSpam_ozemailDOTcomDOTau> wrote

Quote:
It's simple enough to do anyway, but out of interest:

What logging components are there out there?

Do people use them?

What advantages do they offer?

Which ones do you use?

Basically I mean something that would take a handled exception and log
whatever details you give it to file. Normally I'd just log to a text
file,
but if I used a logging component I guess it would be better if it gave me
options, eg to text file, XML, binary, database, etc.

It should do all the obvious and normal things, eg record the error
name/category and details I pass to it, attach a timestamp, attach a
userID
if appropriate, etc.

If it were reasonably clever, it would have logic to allow you to
configure
whether to record every error, or just the first instance of each (perhaps
with a running total of how many times and how frequently it has been
occuring).

Or maybe everyone's logging requirements are individual/specific anyway,
so
everyone just rolls their own.

By logging components, I specifically DON'T MEAN components for catching
UNHANDLED exceptions like MadExcept, EurekaLog, etc. I'm interested in
what
you do (or don't) use to log HANDLED exceptions and errors.

Thanks

Lauchlan M





Back to top
Andrea Raimondi
Guest





PostPosted: Tue May 17, 2005 6:15 am    Post subject: Re: Logging components? Reply with quote

Lauchlan M wrote:
Quote:
What logging components are there out there?

JVCL has one.

Quote:
Do people use them?

If I had a need to, yes I'd use it.

Quote:
What advantages do they offer?

You don't reinvent the wheel :-)

Quote:
Which ones do you use?

JVCL one when needed.

Quote:
Basically I mean something that would take a handled exception and log
whatever details you give it to file. Normally I'd just log to a text file,
but if I used a logging component I guess it would be better if it gave me
options, eg to text file, XML, binary, database, etc.

JVCL only supports CSV and binary.

Quote:
Thanks

Welcome,

Quote:
Lauchlan M

Andrew

Back to top
Matthew Jones
Guest





PostPosted: Tue May 17, 2005 10:16 am    Post subject: Re: Logging components? Reply with quote

I use Raize Codesite, which is simply indispensable when working on user
interface code so you can see what is going on "underneath" without having
to do breakpoints which affect the order in which things happen. But it is
also great for remote debugging - you can deploy the capture system, have
it send to file or network machine, and then gather information. Things
that it captures include the app name and thread ID and timestamp, all of
which ensure you are talking about the right information. The viewer adds
extra value in that you can click on two lines and it shows the time
difference between them. It can also categorise, search, and make coffee.

Well worth a look, and buying too.

/Matthew Jones/
Back to top
Lauchlan M
Guest





PostPosted: Tue May 17, 2005 10:43 am    Post subject: Re: Logging components? Reply with quote

Quote:
I use Raize Codesite, which is simply indispensable when working on user
interface code so you can see what is going on "underneath" without having
to do breakpoints which affect the order in which things happen. But it is
also great for remote debugging - you can deploy the capture system, have
it send to file or network machine, and then gather information. Things
that it captures include the app name and thread ID and timestamp, all of
which ensure you are talking about the right information. The viewer adds
extra value in that you can click on two lines and it shows the time
difference between them. It can also categorise, search, and make coffee.

Well worth a look, and buying too.

Thanks. It sounds similar in some ways to one at Scalabium -
http://www.scalabium.com/smlog/

That functionality isn't really quite what I'm after though. What I want is
to log specific things I tell it to when I tell it to, when a handled
exception occurs.

The closest I've seen thus far in a quick google search is
http://mapage.noos.fr/qnno/pages/hLog_ex.htm

But again that's not really what I would be after (if I use a component for
this at all).

This is how I would imagine the component to be (if it existed):

* You could drop one or more log components on a form (or datamodule to
store them centrally for a project)

* for each log component, you'd set up a number of error field-value pairs
when you double click on the component or a certain property of that
component (eg called 'fields'). The fields would be typed.

* you'd use properties to tell it whether or not to auto-attach stuff like a
timestamp to each log entry (default to true)

* you'd be able to define and use multiple storage formats for the log: to
plain text, csv, XML, bin, and ideally also to a database. You could switch
between these by setting a property, eg called storagetype, and tell it
where to store it with directory and filename properties (which you can also
set at runtime of course).

Then you'd drop a log component for each exception format you want, and set
it up something like

MyLogComponent.Field1.Value := MyInteger1;
....
MyLogComponent.FieldN.Value := MyStringN;
MyLogComponent.LogIt

Then it would be neat to have some way to configure it so that if certain
fields are the same (say the error name you provide and the exception text),
you could get it to log errors only once, but keep a count of how many times
they occured. So you might get a log item for (csv format)

<todays date>,
mainformcreate_error,
EDatabase not available error - database not available,
<total count of times it occurred>,
<frequency of occurence (times/per week)>,
<first occured date>

It would also be threadsafe.

Anyone know of anything like this?

I realise it's not much work to define a MyExceptionLog(a: string, b:
integer . . .); procedure, I'm just looking around to see what (if anything)
is out there.

Lauchlan M



Back to top
Lauchlan M
Guest





PostPosted: Tue May 17, 2005 10:45 am    Post subject: Re: Logging components? Reply with quote

Quote:
This is how I would imagine the component to be (if it existed):

* You could drop one or more log components on a form (or datamodule to
store them centrally for a project)

* for each log component, you'd set up a number of error field-value pairs
when you double click on the component or a certain property of that
component (eg called 'fields'). The fields would be typed.

* you'd use properties to tell it whether or not to auto-attach stuff like
a
timestamp to each log entry (default to true)

oh, and

* whether or not to attach a header row for text files

Quote:
* you'd be able to define and use multiple storage formats for the log: to
plain text, csv, XML, bin, and ideally also to a database. You could
switch
between these by setting a property, eg called storagetype, and tell it
where to store it with directory and filename properties (which you can
also
set at runtime of course).

Then you'd drop a log component for each exception format you want, and
set
it up something like

MyLogComponent.Field1.Value := MyInteger1;
...
MyLogComponent.FieldN.Value := MyStringN;
MyLogComponent.LogIt

Then it would be neat to have some way to configure it so that if certain
fields are the same (say the error name you provide and the exception
text),
you could get it to log errors only once, but keep a count of how many
times
they occured. So you might get a log item for (csv format)

todays date>,
mainformcreate_error,
EDatabase not available error - database not available,
total count of times it occurred>,
frequency of occurence (times/per week)>,
first occured date

It would also be threadsafe.

Anyone know of anything like this?

I realise it's not much work to define a MyExceptionLog(a: string, b:
integer . . .); procedure, I'm just looking around to see what (if
anything)
is out there.

Lauchlan M





Back to top
Matthew Jones
Guest





PostPosted: Tue May 17, 2005 11:45 am    Post subject: Re: Logging components? Reply with quote

Hmm. I sort of see what you want, and agree Codesite does it around the
other way, but it is there and it works. The main thing is that you can
"Send" an object with Codesite, so you could say "Codesite.Send("Current
list", MyListBox);" and the list gets transferred. Basically all the
public properties get sent to the log. Of course you can do this any time
you want, so that could be at exceptions, or whenever you want (or not at
all - the Codesite object becomes "passive" if not enabled).

The advantage that the Codesite way of doing things gives is that you can
output whatever you want whenever you want, and you don't have to
configure something in advance. I can't find a list of the Codesite Object
calls on the Raize website, but
http://www.raize.com/DevTools/CodeSite/Add-Ons/Default.asp has a number of
examples in the templates section. Things like EnterMethod and ExitMethod
allow for some good organisation.

/Matthew Jones/
Back to top
Paul Dolen
Guest





PostPosted: Tue May 17, 2005 3:02 pm    Post subject: Re: Logging components? Reply with quote

Quote:
By logging components, I specifically DON'T MEAN components for catching
UNHANDLED exceptions like MadExcept, EurekaLog, etc. I'm interested in what
you do (or don't) use to log HANDLED exceptions and errors.

In an earlier thread comparing MadExcept and EurekaLog, someone said
that they use MadExcept specifically because it does support logging
of handled exceptions. EurekaLog doesn't, but it might be added
sometime.

Back to top
Uwe Raabe
Guest





PostPosted: Tue May 17, 2005 3:03 pm    Post subject: Re: Logging components? Reply with quote

Have a look at this one:
www.profscomponents.com/code/Components/Logging/Intro.htm
Back to top
Lauchlan M
Guest





PostPosted: Tue May 17, 2005 3:19 pm    Post subject: Re: Logging components? Reply with quote

Quote:
By logging components, I specifically DON'T MEAN components for catching
UNHANDLED exceptions like MadExcept, EurekaLog, etc. I'm interested in
what
you do (or don't) use to log HANDLED exceptions and errors.

In an earlier thread comparing MadExcept and EurekaLog, someone said
that they use MadExcept specifically because it does support logging
of handled exceptions. EurekaLog doesn't, but it might be added
sometime.

Yep, I remember the thread. I have MadExcept.

It's not quite the way I wanted to approach things, but thank you for the
suggestion!

Lauchlan M



Back to top
Lauchlan M
Guest





PostPosted: Tue May 17, 2005 3:20 pm    Post subject: Re: Logging components? Reply with quote

Quote:
Have a look at this one:
www.profscomponents.com/code/Components/Logging/Intro.htm

That one looked quite promising till I looked at the price!

Thanks for the link,

Lauchlan M



Back to top
Doug Olson
Guest





PostPosted: Tue May 17, 2005 4:13 pm    Post subject: Re: Logging components? Reply with quote

I thought the same thing... nice looking products though.

Doug

"Lauchlan M" <LMackinnonAT_NoSpam_ozemailDOTcomDOTau> wrote

Quote:
Have a look at this one:
www.profscomponents.com/code/Components/Logging/Intro.htm

That one looked quite promising till I looked at the price!

Thanks for the link,

Lauchlan M





Back to top
Brian Moelk
Guest





PostPosted: Tue May 17, 2005 4:20 pm    Post subject: Re: Logging components? Reply with quote

Quote:
This is how I would imagine the component to be (if it existed):

The new logging framework in NexusDB V2 gets close.

Quote:
* You could drop one or more log components on a form (or datamodule to
store them centrally for a project)

There are multiple logging components based on how you want to handle the
data you want to log. The most basic is log the data to a text file. There
are others for the Windows event log and an "event-based" logger, where you
can define specific events to handle the log data. There is also a
dispatcher, which lets you hook up multiple loggers and dispatch to the all
with one log call.

Quote:
* for each log component, you'd set up a number of error field-value pairs
when you double click on the component or a certain property of that
component (eg called 'fields'). The fields would be typed.

What you can do is descend from InxLogData and then create your own
TnxLogData class to implement that interface and pass instances through the
framework. This would involve some downcasting however when you want to
actually deal with the data.

Quote:
* you'd use properties to tell it whether or not to auto-attach stuff like
a
timestamp to each log entry (default to true)

That's supported.

Quote:
* you'd be able to define and use multiple storage formats for the log: to
plain text, csv, XML, bin, and ideally also to a database. You could
switch
between these by setting a property, eg called storagetype, and tell it
where to store it with directory and filename properties (which you can
also
set at runtime of course).

Here you would simply enable/disable the various loggers that you have wired
up to your dispatcher. You can write your own Loggers for whatever format
you want XML, DB or even remote logging using RO etc.

Quote:
Then it would be neat to have some way to configure it so that if certain
fields are the same (say the error name you provide and the exception
text),
you could get it to log errors only once, but keep a count of how many
times
they occured. So you might get a log item for (csv format)

You'd probably have to write your own logger for that, but the framework is
there.

Quote:
It would also be threadsafe.

The framework is threadsafe and supports data caching and some other nice
features.

--
Brian Moelk
[email]bmoelk (AT) NObrainendeavorSPAM (DOT) FORc[/email]omME
http://www.brainendeavor.com



Back to top
John McTaggart
Guest





PostPosted: Tue May 17, 2005 5:23 pm    Post subject: Re: Logging components? Reply with quote

Quote:
By logging components, I specifically DON'T MEAN components for catching
UNHANDLED exceptions like MadExcept, EurekaLog, etc. I'm interested in
what
you do (or don't) use to log HANDLED exceptions and errors.

Have you looked at the ones in TurboPower's SysTools package?

If memory serves, they have general, exception and NT event logs..

John McTaggart



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Thirdparty Tools (General) All times are GMT
Goto page 1, 2, 3  Next
Page 1 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.