Can you Increase Log File Size Limit?
# help-with-umbraco
d
If you try and view the Umbraco / serilog files that are above a certain size you get the message: "Today's log file is too large to be viewed and would cause performance problems." So is there a way I can decide how big is too big? I've a powerful desktop with 12 cores / 32GB RAM so I'm pretty sure it would be OK with a larger size. When you are doing stuff like trace-level logging it can easily fill up and trying to read a JSON log file in Notepad++ isn't fun... So can we increase the threshold? How? Alternatively, are there any offline log viewers (eg. stand alone app)? I remember someone wrote one once, but was that for the older log files?
k
@Warren Buckley wrote the compact log viewer you can get it on the Microsoft store (https://apps.microsoft.com/detail/9n8rv8lktxrj?hl=en-us&gl=US) . I use it all the time it's awesome
I think you can change the size if you are using the rolling file config https://stackoverflow.com/questions/40880261/configuring-serilog-rollingfile-with-appsettings-json
w
Yeh use the desktop app & thaks for the plug Kevin
If you really want to run it via the backoffice Dan, from memory there is an property or method on the interface that says how to calculate if it can open so many logs into memory.
It was to avoid having large logs say on a prod being opened and overwhelming the server by loading everything into memory
So you could probably write an implementation that loads when its dev only mode or something if you dont care on your own machine or whatever
d
I should have guess it was you @Warren Buckley that's awesome 👍 Thanks @Kevin Jump for the info. I might play around with the Serilog config for dev, but the app should keep me going. Cheers!
w
No worries
Needs some TLC & UI refresh but as always... not enough time in the day/s
Copy code
csharp
        // The GetLogSize call on JsonLogViewer returns the total file size in bytes
        // Check if the log size is not greater than 100Mb (FileSizeCap)
        var logSizeAsMegabytes = fileSizeCount / 1024 / 1024;
        return logSizeAsMegabytes <= FileSizeCap;
[Obsolete("Use ILogViewerService.CanViewLogsAsync instead. Scheduled for removal in Umbraco 15.")]
so perhaps you can replace the concrete implementation of ILogViewerService with your own?
d
Looks promising , @Mike Chambers 👍
w
Yep sure can replace it. I think I wrote docs sample to read logs from Azure blob at the time. But yep this is the route to go if you wanna replace that logic/chdck
m
I'd also advocate maybe using a different logging engine, we turn off file based logging and instead add in logging to SEQ via a serilog sync.
Copy code
json
"Serilog": {
  "MinimumLevel": {    //Verbose|Debug|Information|Warning|Error|Fatal
    "Default": "Debug",
    "Override": {
      "Microsoft": "Warning",
      "SixLabors.ImageSharp": "Warning"
    }
  },
  "WriteTo": [
    {
      "Name": "Async",
      "Args": {
        "configure": [
          {
            "Name": "Seq",
            "Args": {
              "serverUrl": "https://localhost:5341",
              "restrictedToMinimumLevel": "Information"
            }
          }
        ]
      }
    },
    {
      // not a real sync so can't be in async
      "Name": "UmbracoFile",
      "Args": {
        "RestrictedToMinimumLevel": "Fatal"
      }
    }
  ]
},
As we are talking local dev time here you can have a local instance of seq with improved log functionality as that's its single purpose.. https://datalust.co/ with https://github.com/datalust/serilog-sinks-seq Sql query language for log filtering, and reporting etc... One nice one is the log retention.. set to say 30mins and you machine doesn't fill with logs.... 😉 Also comes into it's own for load balanced setups for aggregating into a single log appliance. You could also use application insights sink too, but for locally logging a little overkill..
also of use is the IDiagnosticContext fo serilog, good series here https://andrewlock.net/using-serilog-aspnetcore-in-asp-net-core-3-reducing-log-verbosity/
w
Yep I would totally go for SEQ if you can in your setups
89 Views