Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Shahzad Ahamad 51 posts 251 karma points
    Mar 15, 2024 @ 18:36
    Shahzad Ahamad
    0

    File size limit rollover is not happening for Log file sin Umbraco 10.7

    Hi All,

    I am trying to add rollover the Log files on a daily basis and on a size limit in case the file size increases more than a set size. But it is not working for me

    I am using the below settings.

    "Serilog": {
      "MinimumLevel": {
        "Default": "Information",
        "Override": {
          "Microsoft": "Information",
          "Microsoft.Hosting.Lifetime": "Information",
          "System": "Information"
        }
      },
      "WriteTo": [
        {
          "Name": "File",
          "Args": {
            "path": "umbraco/Logs/UmbracoTraceLog.txt",
            "rollingInterval": "Day",
            "rollOnFileSizeLimit": true,
            "fileSizeLimitBytes": 50000,
            "retainedFileCountLimit": 7
          }
        }
      ]
    },
    

    Any help or suggestion will be appreciated.

  • Damian 61 posts 342 karma points
    Mar 16, 2024 @ 17:03
    Damian
    0

    Oh! Could it be that you're declaring an explicit file name in the [path]? Instead of Serilog creating new files like path/log_{timestamp}.txt - it is writing over the same file again and again?

  • Shahzad Ahamad 51 posts 251 karma points
    Mar 16, 2024 @ 17:27
    Shahzad Ahamad
    0

    No, initially I tried without explicit file name but it didn't work so I tried with explicit file path. It is not working for both the cases.

  • Damian 61 posts 342 karma points
    Mar 16, 2024 @ 17:29
    Damian
    0

    Dang, sorry it's not that simple.

    I had initially typed out this before noticing the extension:

    I believe Umbraco uses its own sink called "UmbracoFile" . I don't know why/how that might affect a Serilog.Sinks.File, which you appear to be using, but this would be my first suspicion. (purely speculative here!)
    If nothing else, the UmbracoFile sink might open another option to workaround the issue you're seeing. Good luck - I'm rooting for ya!

  • Shahzad Ahamad 51 posts 251 karma points
    Mar 18, 2024 @ 08:46
    Shahzad Ahamad
    0

    Hi Damian, Thank you for your answer. It still didn't work. I am not sure where I am making the mistake. I used the exact code from the documentation but it is still not rolling over after the specified size limit.

    "Serilog": {
      "MinimumLevel": {
        "Default": "Information",
        "Override": {
          "Microsoft": "Information",
          "Microsoft.Hosting.Lifetime": "Information",
          "System": "Information"
        }
      },
      "WriteTo": [
        {
          "Name": "UmbracoFile",
          "Args": {
            "FileSizeLimitBytes": 50000,
            "RollingInterval": "Day",
            "FlushToDiskInterval": null,
            "RollOnFileSizeLimit": true,
            "RetainedFileCountLimit": 31
          }
        }
      ]
    }
    

    enter image description here

  • Damian 61 posts 342 karma points
    Mar 18, 2024 @ 14:09
    Damian
    0

    hmmm…just a quick sanity question - are you rebuilding (and therefore reloading) the app after making the config changes?

  • Shahzad Ahamad 51 posts 251 karma points
    Mar 21, 2024 @ 16:49
    Shahzad Ahamad
    0

    Hi, Sorry for the late answer got busy with something else. Yes I am rebuilding and then checking it again.

Please Sign in or register to post replies

Write your reply to:

Draft