danieleteti / loggerpro

An modern and pluggable logging framework for Delphi
Apache License 2.0
353 stars 91 forks source link

Exception on Syslog Appender when message/payload is too big #83

Closed Basti-Fantasti closed 7 months ago

Basti-Fantasti commented 1 year ago

When sending a big message payload to the logger class like a complex json object, an exception on the Syslog Logger is triggered, when the log message exceeds the allowed packet size (maybe limited by the TCP packet size)

grafik

"Package zu groß" means "package too big" 😄

danieleteti commented 1 year ago

Can you provide a self-contained sample?

Basti-Fantasti commented 1 year ago

Sure :-)

I adjusted your 100_udp_syslog example from the samples folder (see attached zip file) Basically I just commented out the random output of log messages and replaced it with a static function to load the dummy file (also attached), which needs to be copied to the same location as the compiled binary.

procedure TFUDPServerClientForm.UDPClientTimerTimer(Sender: TObject);
var
  SList : TStringlist;
begin
  slist := Tstringlist.Create;
  slist.LoadFromFile('.\dummy.json');
  Log.Debug(slist[0], 'DEBUG');
//  case RandomRange(0, 5) of
//    0: Log.Debug('debug message', 'DEBUG');
//    1: Log.Info('info message', 'INFO');
//    2: Log.Warn('warn message', 'WARN');
//    3: Log.Error('error message', 'ERROR');
//    4: Log.Info('Some Access Violation', 'INFO');
//  end;
  slist.Free;
end;

The Exception only pops up when debugging the application. When the application runs standalone, the message is never sent. I don't know what would be the best/correct approach in that case. Split up the message? Send a warning with "message to long" or "message shortened" ?

dummy.json

UDPServerClientForm.zip

nurettin commented 11 months ago

I don't have access to a copy of Delphi anymore, but the logger wasn't meant for sending large chunks of data over UDP. That would require breaking down the data into 400-500 byte chunks and sending them consecutively.

Now This is just my personal opinion: Not really sure if this needs to be supported. There seems to be something wrong at the architectural level. You simply don't dump your entire mongodb document to a udp logging server. If you are forced by law, at least do it element by element instead of sending the entire array at once?