Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timestamp format when writing to Graylog differs from LogFile and Console #56

Closed
RHV044 opened this issue Apr 15, 2020 · 4 comments
Closed

Comments

@RHV044
Copy link

RHV044 commented Apr 15, 2020

Hello!

I'm having this trouble and I'm not sure if it is indeed an issue.

Every log I get on Graylog (running on localhost btw) is with UTC 0 format, but logfiles and console have my local timezone (this is what I want actually).

Is this something related to graylog damanding UTC 0? or may be an issue on the sink?

This is my Serilog configuration:

"Serilog": {
   "Using": [ "Serilog.Sinks.Graylog", "Serilog.Sinks.File", "Serilog.Sinks.Console" ],
   "MinimumLevel": {
     "Default": "Debug",
     "Override": {
       "Microsoft": "Warning",
       "System": "Warning"
     }
   },
   "WriteTo": [
     {
       "Name": "Graylog",
       "Args": {
         "MinimumLogEventLevel": "Information",
         "hostnameOrAddress": "127.0.0.1",
         "port": "12201",
         "transportType": "Tcp",
         "restrictedToMinimumLevel": "Information",
         "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] #{ThreadId} {Message:lj}{NewLine}{Properties}{NewLine}{Exception}{NewLine}"
       }
     },
     {
       "Name": "File",
       "Args": {
         "restrictedToMinimumLevel": "Information",
         "rollingInterval": 3, //RollingInterval.Day
         "path": "logs/log-.txt",
         "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] #{ThreadId} {Message:lj}{NewLine}{Properties}{NewLine}{Exception}{NewLine}"
       }
     },
     {
       "Name": "Console",
       "Args": {
         "restrictedToMinimumLevel": "Information",
         "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] #{ThreadId} {Message:lj}{NewLine}{Properties}{NewLine}{Exception}{NewLine}"
       }
     }

   ],
   "Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ],
   "Properties": {
     "Application": "app"
   }
 } 
@whir1
Copy link
Contributor

whir1 commented May 18, 2020

outputTemplate does not exist in sink

@RHV044
Copy link
Author

RHV044 commented May 19, 2020

outputTemplate does not exist in sink

Ok thanks, but that doesn't explain the TimeZone diff

@whir1
Copy link
Contributor

whir1 commented May 27, 2020

It's because timestamp - "Seconds since UNIX epoch with optional decimal places for milliseconds" it's graylog field. If you want timestamp with TimeZone you should use another field for that.

@Ghostbird
Copy link

Note that you can set the user's time zone in the Graylog interface. Graylog shows messages in the configured user time zone (which is UTC by default), regardless of the actual timestamp in the log message. Maybe you got confused by that?

@RHV044 RHV044 closed this as completed Apr 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants