SyslogNet icon indicating copy to clipboard operation
SyslogNet copied to clipboard

Wrong (invalid) Syslog Timestamps (depends on location)

Open ndsvw opened this issue 5 years ago • 0 comments

The month of a Syslog timestamp is defined as one of these values: Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec (https://tools.ietf.org/html/rfc3164#section-4.1.2)

But if you are located in special countries (Germany for example, but a lot more), the line timestamp = String.Concat(dt.ToString("MMM "), day, dt.ToString(" HH:mm:ss")); could result in month names like "Mrz", "Dez"...

They are not valid!

This is easily solvable by adding CultureInfo.InvariantCulture as 2nd parameter of DateTime.toString:

timestamp = String.Concat(dt.ToString("MMM ", CultureInfo.InvariantCulture), day, dt.ToString(" HH:mm:ss", CultureInfo.InvariantCulture));

ndsvw avatar Mar 19 '20 18:03 ndsvw