You are not logged in.
Pages: 1
Trying to use angelize I noticed that aLog in the constructor is not used anywhere. Do I miss something?
constructor TSynAngelize.Create(aServiceClass: TSynAngelizeServiceClass;
aLog: TSynLogClass; const aSectionName: RawUtf8;
const aWorkFolder, aSettingsFolder, aLogFolder, aSettingsExt, aSettingsName: TFileName;
aSettingsOptions: TSynJsonFileSettingsOptions);
Secondly, when in windows I start the agl with the -c parameter every log entry created with TSynlog.Add exists in the log file. When I started as a windows service with /start parameter, only log entries before starting the services are logged.
Where the logs entries go?
Thanks in advance
Offline
You are right: TSynLog process is defined by TSynAngelizeSettings.LogClass.
This parameter is not used.
In fact, this low-level TSynLog may be confusing.
In fact, Start calls SetLog() and therefore follow TSynAngelizeSettings.Log/LogPath/LogRotateFileCount parameters.
If you don't overwrite any settings in those fields, you won't have any logs once started.
Offline
In fact, Start calls SetLog() and therefore follow TSynAngelizeSettings.Log/LogPath/LogRotateFileCount parameters.
If you don't overwrite any settings in those fields, you won't have any logs once started.
With the same code from my part I see a difference between running alg with the -c parameter and /start parameter in windows (compiled with Delphi 12)
When running with the -c parameter as console application that waits the "Enter" to finish, everything is OK
When running with the /start parameter as a windows service then log entries come only from the starting process and stops to
20250113 10272931 ! debug mormot.core.os.TServiceController(02ea5658) Start(agl) Args=0 Handle=17568712
No more log entries from the running service can be found in the log, till I stop the service.
Running as a service does not write any log entries to the file. Are they redirected somewhere else?
Offline
Running as a service does not write any log entries to the file. Are they redirected somewhere else?
I have a windows service based on angel project and Tsynagelize
With the following code, after the windows service starts, I have no log entries in the log during the time that the services runs. Tested for hours.
function log2file(const s: rawutf8; const Args: array of const; const deb:boolean=false):boolean;
begin
result:=true;
if not deb then exit;
tsynlog.DoLog(sllCustom4,s,args); end;
With the following function, without any other change in code/configuration, I have log entries from this functions that they have the format of Tsynlog (the appendtofile returns false), even during the windows service runs, after starting/before stopping
function log2file(const s: rawutf8; const Args: array of const; const deb:boolean=false):boolean;
begin
result:=true;
if not deb then exit;
if not AppendToFile(formatutf8(s+#13,args),'agl.log') then tsynlog.DoLog(sllCustom4,s,args);
end;
In both cases the Tsynlog has to send the log entries to agl.log file.
Last edited by dcoun (2025-02-09 13:08:59)
Offline
the same executable (tsynAngelize derived class object), when it runs as a windows services it does NOT log anything after service started. The same executable when it is started with -c parameter, it logs everything ok with Tsynlog
the service runs as LocalSystem "account".
it is created as
inherited create(tmyAngelconfig, nil, etcdirnam, config.workdir.ToString, settingspath+'services', config.LogPath, '.conf', 'agl', [fsoDisableSaveIfNeeded]);
with fsas.LogClass.Family do begin
NoFile:=false;
fsas.Log:=[sllWarning, sllError,sllLastError,sllMemory, sllFail, sllException, sllExceptionOS ];
RotateFileDailyAtHour:=0;
RotateFileCount:=10;
AutoFlushTimeOut:=3;
end;
WebSocketLog:=fsas.LogClass;
fsas.LogRotateFileCount:=10;
I expect the same executable to log the same either started as a windows service either as a console application.
Last edited by dcoun (2025-02-12 06:41:09)
Offline
@dcoun
As I remember I had the same issue with TSynLog for years. It's probably not related to mORMo2 but Windows:
Offline
Thank you for the response. My initial though was about that file permissions can produce the problem even with LocalSystem which is similar to administrator account.
But other files are created when running as a service in the same/different directories, the file permissions include account SYSTEM with full access. Even a mormot's function IsDirectoryWritable("directory",[idwTryWinExeFile,idwWriteSomeContent]); returns true.
My delay in response today, is because I found something interesting:
A mormot function like filefromstring('write this for testing',myfile) does not always produce a file when it runs from a service inside a directory named "c\work":
if myfile is 'c:\work\test\test.txt' the file is produced
if myfile is 'test\test.txt' the file is NOT produced, but it returns TRUE
all other functions for 'test\' like directoryexisting, etc, return true, and let you believe everything is ok
I believe windows write somewhere else the files but I can not find the path, c:\windows\system32, c:\windows\syswow64, and other I tested do not include the files
I did not also find a function to check this kind of path and reform it, in order to avoid such a problem
Last edited by dcoun (2025-02-12 11:17:40)
Offline
Finally with expandfilename I found that c:\windows\system32 is used as root path for services
For the logs, that where the initial problem, the log path provided was not relative, so it should not be caused by the path environment of the windows service. Anyway, I learn a lot for the services from this problem.
I found no solution for the log with Tsynlog.
Finally I used the EchoCustom and nofile=true and all logs are saved now ok in a file with a separate function.
Last edited by dcoun (2025-02-12 12:10:01)
Offline
Pages: 1