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

Sending log to a specific stream #68

Open
fabercs opened this issue Feb 5, 2021 · 2 comments
Open

Sending log to a specific stream #68

fabercs opened this issue Feb 5, 2021 · 2 comments

Comments

@fabercs
Copy link

fabercs commented Feb 5, 2021

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)

@whir1
Copy link
Contributor

whir1 commented Feb 8, 2021

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.

@fabercs
Copy link
Author

fabercs commented Feb 8, 2021

@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.

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

2 participants