#1 2023-03-21 07:12:03

missionhq
Member
From: Australia
Registered: 2019-06-11
Posts: 33

Multiple Log Files with TSynLog

I am currently writing all my log data to a single log file using

with TSQLLog.Family do
  begin { enable logging to file and to console }
    TSQLLog.Family.FileExistsAction:= acAppend;
    DestinationPath:= ServerDataPath + 'Logs\';
    ...

then

TSQLLog.Add.Log(sllInfo, 'My Log Entry');

I want to split things up into separate log files - 1x log file for DB Access, 1 file for logic engine etc
I am a confused how the Logging 'Family' works. It mentions in the code comments that this can be done and so looking for some help in how best to do this.

Thanks in advance...

Offline

#2 2023-03-21 07:36:49

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

Re: Multiple Log Files with TSynLog

Use a sub-class, one per log.

type
  TMyDBLog = type (TSynLog);
  TMyLogicLog = type(TSynLog);

then each class could have its own log family, so you can set a file for each.

But I don't advice to separate the logs.
Use a single log file, with proper event level, is more easy to maintain and to debug, because you can look of the links between the layers. Use the SynLogViewer to filter the log, and only look at what is of interrest (e.g. DB or logic).

Offline

#3 2023-03-21 08:18:54

missionhq
Member
From: Australia
Registered: 2019-06-11
Posts: 33

Re: Multiple Log Files with TSynLog

Cheers ab
I plan to have these additional log files as an option to log some real-time data from various sources. It's coming every few seconds and is good debugging info but is clogging up the regular log file.
I'll give it a try and see how it goes.
Cheers

Offline

#4 2023-03-21 09:14:05

missionhq
Member
From: Australia
Registered: 2019-06-11
Posts: 33

Re: Multiple Log Files with TSynLog

I like the idea of the SynLogViewer though smile

Offline

#5 2023-03-21 09:23:12

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

Re: Multiple Log Files with TSynLog

It is just my personal experience feedback after looking at terrabytes of logs (literally) on 500 mORMot servers working together (in my previous job).

Offline

#6 2023-03-21 21:23:56

missionhq
Member
From: Australia
Registered: 2019-06-11
Posts: 33

Re: Multiple Log Files with TSynLog

ab wrote:

It is just my personal experience feedback after looking at terrabytes of logs (literally) on 500 mORMot servers working together (in my previous job).

Hhah - yes I can relate to that!

Offline

Board footer

Powered by FluxBB