loggerpro icon indicating copy to clipboard operation
loggerpro copied to clipboard

Exception on Syslog Appender when message/payload is too big

Open Basti-Fantasti opened this issue 2 years ago • 3 comments
trafficstars

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" 😄

Basti-Fantasti avatar Oct 24 '23 09:10 Basti-Fantasti

Can you provide a self-contained sample?

danieleteti avatar Oct 24 '23 11:10 danieleteti

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

Basti-Fantasti avatar Oct 24 '23 12:10 Basti-Fantasti

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?

nurettin avatar Nov 24 '23 15:11 nurettin