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

Serilog sinks file - stops logging randomly for a few hours #327

Open
die-baas opened this issue Nov 21, 2024 · 1 comment
Open

Serilog sinks file - stops logging randomly for a few hours #327

die-baas opened this issue Nov 21, 2024 · 1 comment
Labels

Comments

@die-baas
Copy link

We have a development/test web application running that uses Serilog.Sinks.File for logging. For no reason we have been able to ascertain, logging will stop for a few hours and then resume by itself. It happens daily, at different times of the day.

Code to initialize

        public static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args)
                .ConfigureWebHostDefaults(webBuilder =>
                {
                    webBuilder.UseStartup<Startup>();
                })
                .UseSerilog((hostingContext, loggerConfiguration) =>
                        loggerConfiguration.ReadFrom.Configuration(hostingContext.Configuration)
                );
    }

Appsettings.Json

  "Serilog": {
    "MinimumLevel": {
      "Default": "Warning",
      "Override": {
        "Default": "Information",
        "Microsoft": "Warning",
        "System": "Warning"
      }
    },
    "WriteTo": [
      {
        "Name": "File",
        "Args": {
          "path": "c:/temp/Logs/Log.txt",
          "retainedFileCountLimit": 30,
          "rollingInterval": "Day"
        }
      }
    ],
    "Enrich": [ "FromLogContext", "WithMachineName" ]
  },

Log file extract

2024-11-21 14:53:07.742 +02:00 [ERR] Client script error: Uncaught TypeError: n.includes is not a function 
2024-11-21 15:01:33.054 +02:00 [ERR] An unhandled exception has occurred while executing the request.
System.InvalidCastException: Unable to cast object of type 'System.DBNull' to type 'System.Int32'.
2024-11-21 15:14:29.401 +02:00 [ERR] An unhandled exception has occurred while executing the request.
System.InvalidCastException: Unable to cast object of type 'System.DBNull' to type 'System.Int32'.

****** Nothing logged for 3.5 hours ******

2024-11-21 18:44:38.579 +02:00 [ERR] Data error on db, Could not find stored procedure 'x'.
2024-11-21 18:49:24.851 +02:00 [ERR] Data error on db, Could not find stored procedure 'x'.
2024-11-21 18:56:36.714 +02:00 [ERR] Client script error: Uncaught TypeError: Cannot read properties of undefined (reading 'top') 
2024-11-21 19:03:23.891 +02:00 [ERR] Data error on db, Could not find stored procedure 'x'.
2024-11-21 19:15:35.261 +02:00 [ERR] Data error on db, Could not find stored procedure 'x'.
2024-11-21 19:24:13.869 +02:00 [ERR] Data error on db, Could not find stored procedure 'x'.

Please advise if it is a config issue or something else?

@die-baas die-baas added the bug label Nov 21, 2024
@nblumhardt
Copy link
Member

Hi! Try enabling SelfLog and have this write to a different location (or directly to a remote endpoint) - if the issue is within the file sink it's likely some info will be produced there. HTH!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants