Ok, to make it more clear
If there is global function which have error/exception output to command line, it can also have output to file without including extra code, just with some compiler command.
Yes, there is such a function in system that you can hook into. You still need some of the code from ASerge to obtain the frames if you use sysutils/structured exception handling.
https://www.freepascal.org/docs-html/rtl/system/writeerrorstostderr.htmlSubsequently make sure you redirect sderr to file.
There are more options (ExitProc and the likes) but that is the easiest.
And it should not be done with a compiler command, you should write (very little) code for it.
example:
program erroutput;
{$mode delphi}{$H+}
var
d:integer = 0;
begin
Assign(stderr,'errorlog.txt');
Rewrite(stderr);
writeln(100 div d);
end.
~ $ cat errorlog.txt
Runtime error 200 at $00010124
$00010124
Is that what you mean? Any errors will be redirected to errorlog.txt in this case (well, almost any....there are obvious exceptions, like errors accessing errorlog.txt...or out of resources or memory)
Under Windows you *must* set writeerrorstostderr to true. Under Linux this is not necessary.