serilog-contrib / Serilog.Sinks.Telegram.Alternative

Serilog.Sinks.Telegram.Alternative is a library to save logging information from Serilog to Telegram.
MIT License
36 stars 12 forks source link

LogEventLevel is not being respected with Serilog overrides #6

Closed zoinkydoink closed 7 months ago

zoinkydoink commented 3 years ago

When I have the following:

"Serilog": {
    "Using": [ "Serilog.Sinks.Console" ],
    "MinimumLevel": "Information",
    "Override": {
      "Microsoft": "Warning",
      "System": "Error"
    },
    "WriteTo": [
        { "Name": "Console" },
        {
          "Name": "Seq",
          "Args": { "serverUrl": "http://logserver:5341" }
        },
        {
          "Name": "Telegram",
          "Args": {
            "botToken": "id",
            "chatId": "id",
            "restrictedToMinimumLevel": "Information"
          }
        }
      ]

    }

Telegram Sink should NOT be printing 'Information' level logs from Microsoft as I had defined a override to only show Warnings from Microsoft and Errors from System.

Basically the Telegram Sink should respect the overrides

SeppPenner commented 3 years ago

So, this does I thought, that this was fixed with the commit that closed https://github.com/SeppPenner/Serilog.Sinks.Telegram/issues/3 already.

zoinkydoink commented 3 years ago

I am not sure if that other but addresses this one. While the restrictToMinimumLevel addresses the issue I am having.

while the new flag works great... but it doesn’t check Serilog overrides

if I set restrictToMinimumLevel to Information It should print all information and above, but if I have a override that says minimum is Warning for Microsoft and System It should only print warning from Microsoft packages and system but continue to print Information for other packages/custom code

SeppPenner commented 3 years ago

I guess, you're right, this is not addressed yet. I will need to investigate on this more as I don't have an idea yet how this is done in Serilog / should be done in sinks.

zoinkydoink commented 3 years ago

I assumed that if I provided the overrides, serilog would be smart enough NOT to send the events if they are already overrides but it seems to pass them to the sinks anyways


From: HansM notifications@github.com Sent: Thursday, January 28, 2021 3:44:04 PM To: SeppPenner/Serilog.Sinks.Telegram Serilog.Sinks.Telegram@noreply.github.com Cc: zoinkydoink zoinky@gmail.com; State change state_change@noreply.github.com Subject: Re: [SeppPenner/Serilog.Sinks.Telegram] LogEventLevel is not being respected with Serilog overrides (#6)

I guess, you're right, this is not addressed yet. I will need to investigate on this more as I don't have an idea yet how this is done in Serilog / should be done in sinks.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHubhttps://github.com/SeppPenner/Serilog.Sinks.Telegram/issues/6#issuecomment-769376983, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADZWBGXLSFXM36ZFKEDM3VLS4HEBJANCNFSM4WR7XNZQ.

SeppPenner commented 3 years ago

I assumed that if I provided the overrides, serilog would be smart enough NOT to send the events if they are already overrides but it seems to pass them to the sinks anyways

I'm not sure, maybe the sink is just using it wrong. I will check this.

zoinkydoink commented 3 years ago

https://github.com/serilog/serilog/issues/1382

SeppPenner commented 3 years ago

Mhm, so this is blocked for now...

zoinkydoink commented 3 years ago

I think the SO post mentioned there uses filtering that can be used here but I am not sure


From: HansM notifications@github.com Sent: Friday, January 29, 2021 2:56:23 AM To: SeppPenner/Serilog.Sinks.Telegram Serilog.Sinks.Telegram@noreply.github.com Cc: zoinkydoink zoinky@gmail.com; State change state_change@noreply.github.com Subject: Re: [SeppPenner/Serilog.Sinks.Telegram] LogEventLevel is not being respected with Serilog overrides (#6)

Mhm, so this is blocked for now...

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHubhttps://github.com/SeppPenner/Serilog.Sinks.Telegram/issues/6#issuecomment-769643182, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADZWBGQHIHTNXINZPO4V3ZDS4JS2PANCNFSM4WR7XNZQ.

SeppPenner commented 3 years ago

I would like to wait for this until it's supported natively from Serilog.

The workaround seems to be that users can use on their own I would say: https://stackoverflow.com/questions/62341787/how-can-i-override-serilog-levels-differently-for-different-sinks. I don't want to include it in the sink directly for now, to be honest.

SeppPenner commented 7 months ago

I would close this now as Serilog doesn't seem to change something here in the main repository...