BedeGaming / sinks-rollingfile

A serilog sink for rolling files based on size and time
Apache License 2.0
15 stars 20 forks source link

Create always new empty file ontop #48

Open RoCore opened 6 years ago

RoCore commented 6 years ago

Hi,

I do have two serilog sinks. mssql and rollingfile. Somehow there is a strange behavior. If the application starts, the rollingfile create always an empty log file (see the pic below). Do I have some misconfigs?

image

"Serilog": {
    "MinimumLevel": "Warning",
    "WriteTo": [
      {
        "Name": "MSSqlServer",
        "Args": {
          "connectionString": "",
          "tableName": "SeriLogs"
        }
      },
      {
        "Name": "RollingFileAlternate",
        "Args": {
          "logDirectory": ".\\logs",
          "fileSizeLimitBytes": 1048576
        }
      }
    ]
  }

nugets


    <PackageReference Include="FluentValidation" Version="7.3.4" />
    <PackageReference Include="FluentValidation.AspNetCore" Version="7.3.4" />
    <PackageReference Include="Microsoft.AspNetCore" Version="2.0.1" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.2" />
    <PackageReference Include="Microsoft.AspNetCore.ResponseCompression" Version="2.0.1" />
    <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.0.1" />
    <PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="2.0.0" />
    <PackageReference Include="Microsoft.Extensions.Logging" Version="2.0.0" />
    <PackageReference Include="Microsoft.Extensions.PlatformAbstractions" Version="1.1.0" />
    <PackageReference Include="Serilog.AspNetCore" Version="2.1.0" />
    <PackageReference Include="Serilog.Settings.Configuration" Version="2.4.0" />
    <PackageReference Include="Serilog.Sinks.MSSqlServerCore" Version="1.1.0" />
    <PackageReference Include="Serilog.Sinks.RollingFileAlternate" Version="2.0.9" />
    <PackageReference Include="Swashbuckle.AspNetCore" Version="1.1.0" />
se7vanj commented 5 years ago

I am also facing the same issue empty 0KB files created.

File size limit set to 4MB per file, the content actually goes to the sink (RollingFileAlternate) and it rolls the files but does not really writes the contents? it was lost. As we see more files with numbers.

It did work for 2 days after that it stopped working even after restarting AppPool & Machine.

Initially I doubted it is something to do with calling CloseAndFlush (which I am calling during OnExit/OnError events), but it doesn't look like the problem!

image

Below are the packages that I use:

`

`