borni69 1 Posted March 22, 2022 Hi , I am trying to make a custom logg work in Linux , but it make the ISAPI stop running It works great in windows. I have this CustomLoggerConfigU.pas unit CustomLoggerConfigU; interface uses LoggerPro; // loggerpro core function GetLogger: ILogWriter; implementation uses System.IOUtils , LoggerPro.FileAppender // loggerpro file appender (logs to file) {$IFDEF MSWINDOWS} , LoggerPro.OutputdebugStringAppender {$ENDIF} // loggerpro outputdebugstring appender (logs to the debugger) ; function GetLogger: ILogWriter; begin Result := BuildLogWriter([ {$IFDEF MSWINDOWS} TLoggerProFileAppender.Create(10, 1000, 'C:\hseqsetting\logs') {$ENDIF} {$IFDEF LINUX} TLoggerProFileAppender.Create(10, 1000, '/etc/hseq/logs') {$ENDIF} ], nil,TLogType.info); end; end. and in my webmodule i have added MVCFramework.Logger to uses and use the following code to trigger SetDefaultLogger ........ procedure TMyWebModule.WebModuleDestroy(Sender: TObject); begin FMVC.Free; end; initialization DataModuleDict:= TDataModuleDict.Create(nil); DataModuleDict.initDict; SetDefaultLogger(GetLogger); finalization DataModuleDict.Free; end. System run ok if I remove SetDefaultLogger(GetLogger); , but if it is present i get this line in terminal, but after it hang root@5e5f9a598ac5:/etc/hseq/logs# cat libmod_hseq2.00.dmvcframework.log 2022-03-22 18:57:54:100 [TID 274930554752][INFO ] Custom Logger initialized [dmvcframework] root@5e5f9a598ac5:/etc/hseq/logs# So its initialized but then hole system hang... not able to run before i comment out line below //SetDefaultLogger(GetLogger); Is this not the correct way to do this on Linux ? thanks in advance Share this post Link to post
borni69 1 Posted March 24, 2022 (edited) The problem was access in my docker file I added the file libmod_hseq2.00.dmvcframework.log and chmod 0777 libmod_hseq2.00.dmvcframework.log then it works so now it seems to log fine to this file /var/log/hseq/libmod_hseq2.00.dmvcframework.log But I got a new problem I would like to send this file to "stdout" Tried using this command RUN ln -sf /dev/stdout /var/log/hseq/libmod_hseq2.00.dmvcframework.log It gives me no error but no logging is showing using docker logs <dockername> I did find something about it maybe not working because it's not in PID1? Any idea Edited March 25, 2022 by borni69 Share this post Link to post
borni69 1 Posted March 24, 2022 (edited) I will also have a look at Restappender, maybe it is a better solution for me... Edited March 24, 2022 by borni69 Share this post Link to post
borni69 1 Posted March 25, 2022 Also if someone needs it later I added the logger in the create part of TMVCEngine procedure TMyWebModule.WebModuleCreate(Sender: TObject); begin FMVC := TMVCEngine.Create(Self, procedure(Config: TMVCConfig) begin // session timeout (0 means session cookie) Config[TMVCConfigKey.SessionTimeout] := '0'; // default content-type Config[TMVCConfigKey.DefaultContentType] := TMVCConstants.DEFAULT_CONTENT_TYPE; // default content charset Config[TMVCConfigKey.DefaultContentCharset] := TMVCConstants.DEFAULT_CONTENT_CHARSET; // unhandled actions are permitted? Config[TMVCConfigKey.AllowUnhandledAction] := 'false'; // default view file extension Config[TMVCConfigKey.DefaultViewFileExtension] := 'html'; // view path Config[TMVCConfigKey.ViewPath] := 'templates'; // Enable Server Signature in response Config[TMVCConfigKey.ExposeServerSignature] := 'true'; end,GetLogger); //GetLogger // Added the logger at this stage FMVC.AddController(TMyController); 1 Share this post Link to post
Daniele Teti 27 Posted March 28, 2022 (edited) On 3/25/2022 at 9:17 AM, borni69 said: > Also if someone needs it later I added the logger in the create part of TMVCEngine Can you fill an issue about this? Also did you tried the setcustomlogger? Are you sure the problem is the instant where the logger is created? Edited March 28, 2022 by Daniele Teti Share this post Link to post
borni69 1 Posted March 28, 2022 (edited) 2 hours ago, Daniele Teti said: Can you fill an issue about this? Also did you tried the setcustomlogger? Are you sure the problem is the instant where the logger is created? In the create FMVC := TMVCEngine.Create I send in a custom logger like below GetLogger end,GetLogger); //GetLogger // Added the logger at this stage unit CustomLoggerConfigU; interface uses LoggerPro; // loggerpro core function GetLogger: ILogWriter; implementation uses System.IOUtils , LoggerPro.FileAppender ; function GetLogger: ILogWriter; begin Result := BuildLogWriter([ {$IFDEF MSWINDOWS} TLoggerProFileAppender.Create ( 10, 1000 , 'C:\hseqsetting\logs' ) {$ENDIF} {$IFDEF LINUX} TLoggerProFileAppender.Create ( 10, 1000 , '/etc/hseq/logs' ) {$ENDIF} ], nil,TLogType.Info); end; end. is this above what you mean with setcustomlogger ? This is an ISAPI app .so for Linux Apache. It was not able to create the file in the location I set in GetLogger But if I added a file manually and set chmod 0777 libmod_hseq2.00.dmvcframework.log to the file, it worked. But after the file logging worked, I was not able to use /dev/stdout My plan was to send the log to AWS cloud watch together with the apache log. So I have for now instead created a custom logger for MYSQL. I can of course be my little knowledge of the framework, and this is not an issue, but I was not able to find any examples for ISAPI Linux using log, and based on my reading I could not make it work. Do you still think I should make it an issue? Also the linux docker is Ubuntu 18.04 Edited March 28, 2022 by borni69 Share this post Link to post