#1 2020-06-28 10:49:12

vjpbiuh
Member
Registered: 2020-01-06
Posts: 2

log stack with two services

hey,

After Creating 2 services , the log get stuck.
c:\mik4win\Service.exe 1.0.0.0 (2020-06-24 14:00:56)
.. some computer data here...
TSynLog 1.18.5369 2020-06-28T10:26:49


and it hangs there.
the process is not login

the log is defined as such:

var
  Log: TSynLog;

function InitLogger :TSynLog ;
begin
with TSynLog.Family do begin
    Level := LOG_VERBOSE;
    Level := [sllInfo,sllException,sllExceptionOS];
    PerThreadLog := ptOneFilePerThread;
    OnArchive := EventArchiveSynLZ;
    ArchiveAfterDays := 3; // archive after one day
    RotateFileCount := 7;        // will maintain a set of up to 5 files
    RotateFileSizeKB := 1024; // rotate by 1 MB logs
    DestinationPath := 'c:\folder\';
  end;
  Result   := TSynLogClass.Create(TSynLog.Family);
end;

using version 1.18

any idea why?
anyone tried testing the logger with services?

Last edited by vjpbiuh (2020-06-28 11:09:22)

Offline

#2 2020-06-28 12:25:22

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: log stack with two services

We use TSynLog on services on production since years, with PB of logs correctly generated, sometimes with dozen of services on the same instances.

You are using TSynLog directly, which is NOT the correct way.

You should use the class, not a custom TSynLog instance.
The TSynLog instance should be allocated by the class methods, like TSynLog.Add or TSynLog.Enter.

I understand it may sound disturbing, but it is the way found to efficiently use a per-thread log if needed.

Offline

#3 2020-06-29 09:17:11

vjpbiuh
Member
Registered: 2020-01-06
Posts: 2

Re: log stack with two services

Thank you very much for your response. I have changed the code to use the metaclass. where is the best place to set the values of the meta class TSynLog?
1. dpr after the begin?
2. initialization on the thread class?
3. initialization  on the service class?
4. on the on start even of the service?
5. on the execute of the thread?

Offline

#4 2020-06-29 11:25:51

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: log stack with two services

6. When you expect to start loging. smile

which is probably as soon as possible - possibly in the dpr, or when the settings have been read from disk.
There is a settings class in mORMotService.pas which allows custom logging, for instance.

Offline

Board footer

Powered by FluxBB