Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2014-05

EventLog and error "No member is provided to access property"

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

silvioprog

Hello,
I'm trying to set a own instance in EventLog property of all apps like TCustomHttpApplication, TCustomCGIApplication and TCustomFCGIApplication, but, no success.

To get the error, try:

TMyHttpApplication = class(TCustomHttpApplication) ...

constructor TMyHttpApplication.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  EventLog := TMyEventLog.Create(Self);
...

I saw this code:

  TCustomWebApplication = Class(TCustomApplication)
...
  Public
    Property EventLog: TEventLog read GetEventLog;

Seems good changing it to:

    Property EventLog: TEventLog read GetEventLog write FEventLog;

So the code below will get my own instance instead of default instance:

function TCustomWebApplication.GetEventLog: TEventLog;
begin
  if not assigned(FEventLog) then
    begin
    FEventLog := TEventLog.Create(Nil);
    FEventLog.Name:=Self.Name+'Logger';
    FEventLog.Identification:=Title;
    FEventLog.RegisterMessageFile(ParamStr(0));
    FEventLog.LogType:=ltSystem;
    FEventLog.Active:=True;
    end;
  Result := FEventLog;
end;

Thank you!

P.S.: Lazarus 1.2.2 r44758 FPC 2.6.4 i386-win32-win32/win64

Silvio Clécio My public projects - github.com/silvioprog

Reply by email

Michael Van Canneyt
to silvioprog
silvioprog wrote
Hello, I'm trying to set a own instance in EventLog property of all apps like TCustomHttpApplication, TCustomCGIApplication and TCustomFCGIApplication, but, no success. To get the error, try:

I have done this differently.
The eventlog instance is owned by the application, so it should not be directly settable.

I created a protected virtual method CreateEventLog that must return a configured TEventLog descendent instance. You can override this method and return whatever you want, as long as it descends from TEventLog.

Revision 27790.

Michael.

Reply by email

silvioprog
to Michael Van Canneyt

2014-05-14 15:14 GMT-03:00 Michael Van Canneyt :

Show quoted text 22 lines
On Tue, 13 May 2014, silvioprog wrote: > Hello, > I'm trying to set a own instance in EventLog property of all apps > like TCustomHttpApplication, TCustomCGIApplication > and TCustomFCGIApplication, but, no success. > > To get the error, try: > I have done this differently. The eventlog instance is owned by the application, so it should not be directly settable. I created a protected virtual method CreateEventLog that must return a configured TEventLog descendent instance. You can override this method and return whatever you want, as long as it descends from TEventLog. Revision 27790. Michael.

Thanks a lot guy! (y)

Silvio Clécio My public projects - github.com/silvioprog

Reply by email