Serilog Filter expression "ByExcluding" - Stack Overflow

I need the logs as followsHealth Check should have single log entry for healthlive and healthready

I need the logs as follows

  1. Health Check should have single log entry for /health/live and /health/ready when Status 200. Currently 3 log entries for /health/live 3-10 log entries for /health/ready.
  2. Health Check should log all the warning and other Status code.

With no filters I could see the below logs

[11:19:19] [7b88516f-aa4b-4e9f-a8f0-9264e48ef899] [56e93ef5-dd95-4743-99d7-873b6132655d] [INF] Request starting HTTP/1.1 GET http://localhost:8800/health/live - null null (Microsoft.AspNetCore.Hosting.Diagnostics)
[11:19:20] [7b88516f-aa4b-4e9f-a8f0-9264e48ef899] [56e93ef5-dd95-4743-99d7-873b6132655d] [INF] Executing endpoint 'Health checks' (Microsoft.AspNetCore.Routing.EndpointMiddleware)
[11:19:20] [7b88516f-aa4b-4e9f-a8f0-9264e48ef899] [56e93ef5-dd95-4743-99d7-873b6132655d] [INF] Executed endpoint 'Health checks' (Microsoft.AspNetCore.Routing.EndpointMiddleware)
[11:19:20] [7b88516f-aa4b-4e9f-a8f0-9264e48ef899] [56e93ef5-dd95-4743-99d7-873b6132655d] [INF] HTTP GET /health/live responded 200 in 776.3736 ms (Serilog.AspNetCore.RequestLoggingMiddleware)
[11:19:20] [7b88516f-aa4b-4e9f-a8f0-9264e48ef899] [56e93ef5-dd95-4743-99d7-873b6132655d] [INF] Request finished HTTP/1.1 GET http://localhost:8800/health/live - 200 null application/json 779.5505ms (Microsoft.AspNetCore.Hosting.Diagnostics)

When I have the Filter as below and what is does is commented above on each filter

  "Filter": [
    {
      "Name": "ByExcluding",
      "Args": {
        // I could see no logs at all
        //"expression": "RequestPath like '/health/%' and not (@Message like '%Request finished%')"
        // on the below ones I see the last log of Request Finished is exlcuded and rest are logged
        //"expression": "RequestPath like '/health/%' and StatusCode = 200"
        //"expression": "RequestPath like '/health/%' and StatusCode = 200 and @Message not like '%Request finished%'"
      }
    }
  ],

When I have the Filter as below and what is does is commented above on each filter

  "Filter": [
    {
      "Name": "ByExcluding",
      "Args": {
        // I could see no logs at all
        //"expression": "RequestPath like '/health/%' and not (@Message like '%Request finished%')"
        // on the below ones I see the last log of Request Finished is exlcuded and rest are logged
        //"expression": "RequestPath like '/health/%' and StatusCode = 200"
        //"expression": "RequestPath like '/health/%' and StatusCode = 200 and @Message not like '%Request finished%'"
      }
    }
  ],

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745309329a4621907.html

相关推荐

  • Serilog Filter expression "ByExcluding" - Stack Overflow

    I need the logs as followsHealth Check should have single log entry for healthlive and healthready

    12小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信