1

I am following this guide to log to Syslog (Log4net: SysLog Appender Example)

All is working! but how do I set the date and time values (not format) to one I specifically want rather that one defined by system? I am trying to insert a backlog of logs and some of these are a day(s) old and only get inserted when the system can connect to the logging service I am building.

I've been tinkering but I have not been having any luck:

<appender name="AuditAndLog" type="log4net.Appender.RemoteSyslogAppender">
<facility value="local7" />
<identity value=" %P{CustomDateTime} %P{log4net:HostName} %P{app}" />
<RemoteAddress value="192.168.33.46" />
<layout type="log4net.Layout.PatternLayout" value="&#9;%P{pid}:%logger %m%n"/>
<RemotePort value="514" />
</appender>

Example in picture. The message is actually for 2020-01-06 but because I am inserting it today, it is appearing at today's date (2020-19-02). I would like to manipulate the date time stamp shown in logs please to show 2020-01-06.

enter image description here

PKCS12
  • 407
  • 15
  • 41
  • 1
    the date format is specified in xml here : dd/MM/yyyy hh:mm:ss,fff See MSDN for description : https://learn.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings – jdweng Feb 19 '20 at 14:38
  • It's not the format of date time that I would like to adjust. thanks – PKCS12 Feb 20 '20 at 08:56
  • 1
    You can't, at least not with `RemoteSyslogAppender`, as it has no support for that, as outlined in its documentation -- it doesn't supply any timestamp, so what you're seeing there is the timestamp generated by whatever's getting the messages. If you need that, you're looking at writing your own appender class. Fortunately syslog isn't a very complicated protocol and log4net is [open source](https://github.com/apache/logging-log4net/blob/master/src/Appender/RemoteSyslogAppender.cs). – Jeroen Mostert Feb 20 '20 at 12:51

0 Answers0