You are not logged in.
Hello ab,
Few years ago I asked a question about how to make TSynLog on the server-side to ignore exceptions that happened inside a try...except block, and you opinion was that all exceptions should be logged.
Now I'm facing an issue that might change your view.
I have a log interception procedure (achieved via TSynLogFamily.EchoCustom) which emails out log entries through SMTP, and when the network is broken or something like that happen, never-ending logging will happen - TSynLog will log any exceptions happened in my "EchoCustom" procedure, and my "EchoCustom" will again trying to send that exception and another exception will happen due to the network issue.
I hope I described the issue clealry.
And a best solution for such cases would be to have an option to disable TSynLog (such as SQLite3Log) logging exceptions I want to ignore (using try...except without re-raising)
Thank you!
Last edited by edwinsn (2020-04-18 08:44:43)
Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.
Offline
You can disable logging such exceptions when sending the mail. It is already possible or for a given class or for any class. Then reinstall the exception handler for normal code. This is what is done with remote logging.
Offline
@ab,
I looked at the code in TSynLog.DisableRemoteLog, but such approach doesn't seem will work in my case, because my 'SMTP remote logging' works like this:
1 - My EchoCustom will not directly send the log entries but just push them to a TSynQueue.
2 - Then another thread will pull from the log queue and send them through SMTP one by one.
The exceptions happens in step 2 is what I want to ignore by TSynLog.
Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.
Offline
ok, worked it around using the good old approach - OnBeforeException - which is my little contribution
I ignores the exceptions by detecting the thread name.
But I still wish there is a global option for disabling TSynLog auto-capturing all the exceptions including those already wrapped by 'try...except', because even in the mORMot threads there are some exceptions I want to ignore...
Last edited by edwinsn (2020-04-18 14:42:27)
Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.
Offline
Offline
Thank you ab! The new `TSynLogFamily.ExceptionIgnorePerThread property` seems to be very helpful in such cases!
Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.
Offline