serilog-sinks-graylog
serilog-sinks-graylog copied to clipboard
Sending log to a specific stream
I am using 2.0 version of this library for my Asp.Net 4.5.1 project. I am trying to send my logs to our company server which has specific streams for each application in the company. I couldn't achieve to see my logs on the server dashboard.
Here my code.
_logger = new LoggerConfiguration()
.WriteTo.Graylog(new GraylogSinkOptions {
HostnameOrAddress = "server",
Port =port,
TransportType = TransportType.Udp
})
//.Enrich.WithProperty("LogSource", "applicationName")
.Enrich.WithProperty("AdditionalFields" , new { application = "applicationName" })
.MinimumLevel.Information()
.CreateLogger();
I am not sure but Graylog GELF specification expects an applicationName for the stream, how can I send these additional fields via this (Serilog graylog) extension? (Tried with Enrich api but not worked)
https://docs.graylog.org/en/4.0/pages/gelf.html
@fabercs the GELF specification not expect application name as required field. try configure logger like
var applicationName = "MyApplicationName";
_logger = new LoggerConfiguration()
.WriteTo.Graylog(new GraylogSinkOptions {
HostnameOrAddress = "server",
Port =port,
TransportType = TransportType.Udp
})
.Enrich.WithProperty("ApplicationName" , applicationName )
.MinimumLevel.Information()
.CreateLogger();
send some logs, and try to find it in all logs stream. After that make stream rules as you want.
@whir1 Thank you for your answer, in our Graylog configuration, a stream is configured as an applicationName field required. So later, I did exactly what you post, but still, no log received. Also, to ensure I tried with a .net core project if stream accepts any log for the given application name. So, I could get logs from that project. I am not sure what I am missing.