简体   繁体   English

SeriLog fileSizeLimitBytes属性asp.net核心

[英]SeriLog fileSizeLimitBytes attributes asp.net Core

We are using asp.net Core 1.1 and are using SeriLog to create log file within the application. 我们正在使用asp.net Core 1.1,并且正在使用SeriLog在应用程序中创建日志文件。

Now to control size of log file, I added attribute fileSizeLimitBytes 现在,为了控制日志文件的大小,我添加了属性fileSizeLimitBytes

"Serilog": {
  "MinimumLevel": "Debug",
  "WriteTo": [
    {
      "Name": "RollingFile",
      "Args": {
        "pathFormat": "Logs/LogFileConf-{Date}-test.Log",
        "fileSizeLimitBytes": 500000
      }
    }
  ],
  "Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ],
  "Properties": {
    "Application": "Sample",
    "Environment": "Test"
  }
},

In this case, writing to log file stopped and when I removed above attributes, writing to log file again started working 在这种情况下,停止写入日志文件,并且当我删除了以上属性后,再次开始写入日志文件

So I have added as follows "pathFormat": "Logs/LogFileConf-{Date}-test.Log", "fileSizeLimitBytes": 500000 因此,我添加了以下“ pathFormat”:“ Logs / LogFileConf- {Date} -test.Log”,“ fileSizeLimitBytes”:500000

I am not sure what I am missing here. 我不确定我在这里缺少什么。

Project.json contains following reference.
"Serilog.Extensions.Logging": "1.2.0",
"Serilog.Sinks.RollingFile": "3.0.1",
"Serilog.Settings.Configuration": "2.1.0"

Can anybody help here to solve this issue? 有人可以在这里解决这个问题吗?

Is your log file already > 500,000 bytes? 您的日志文件是否已经> 500,000字节? That's not a high limit, so chances are the logging stops because the file is already above it. 这不是一个很高的限制,所以由于文件已经在上面,因此记录停止的机会很大。

See Serilog.Sinks.File 4.0+ if you are looking for roll-on-file-size. 如果要查找滚动文件大小,请参见Serilog.Sinks.File 4.0+。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM