danieleteti / loggerpro

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

Wrong Message Priority in UDPSyslogAppender for Several Classes #56

Closed Basti-Fantasti closed 1 year ago

Basti-Fantasti commented 2 years ago

When sending a message to the logger of several types, a generic Syslog Server receives the wrong priority levels.


log.error('Something', '')` => warning
log.warning('Something'. '') => notice

Info and debug are fine. The problem is in the numeric constants for the Syslog Severity

Here's the official list of syslog severity levels:

[SysLogSeverity]
7=slDebug
6=slInformational
5=slNotice
4=slWarning
3=slError
2=slCritical
1=slAlert
0=slEmergency

I have corrected lines 127 - 138 in LoggerPro.UDPSyslogAppender.pas accordingly for .Warning and .Error:

  case pLogItem.LogType of
    TLogType.Debug:
      FPriority := RFC5424Priority(1, 7);
    TLogType.Info:
      FPriority := RFC5424Priority(1, 6);
    TLogType.Warning:
      FPriority := RFC5424Priority(1, 4); // 4 = slWarning
    TLogType.Error:
      FPriority := RFC5424Priority(1, 3); // 3 = slError
  end;
  if pLogItem.LogMessage.Contains('Access Violation') then
    FPriority := RFC5424Priority(1, 2); // 2 = slCritical

now the log priority levels are sent as expected. I also set the severity for the Access ViolationMessages to one level above error (critical = 2)