如果stdoutLogEnabled为true,Serilog控制台是否写入IIS日志文件?

时间:2019-01-08 16:00:34

标签: iis asp.net-core .net-core serilog

我正在通过控制台接收器将Core 2.2与Serilog一起使用。在本地,通过Kestrel效果很好。我的控制台打开,我收到大量日志。当我转到IIS时,这会更改。如果我将stdoutLogEnabled翻转为true,然后创建一个日志目录并将其命名为“所有人-修改” ACL,则实际上我会得到一个文件,并得到输出:

Hosting environment: Production
Content root path: C:\inetpub\wwwroot\mysites\myapp-api
Application started. Press Ctrl+C to shut down.

但是就是这样。。我的应用抛出500个错误,但未记录任何内容。在本地,在控制台窗口中,我可以看到所有这些日志。如果Serilog通过Stdout登录到控制台,那是什么问题?

此外,我尝试添加文件接收器并对其进行配置,但是我无法让Serilog生成文件。我想也许我走错了路?我假设如果得到上述日志,则不是ACL的问题,Serilog应该能够写。但这是另一个问题。

如果有关系,我已经在我的Web项目中启用了<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>

Serilog配置:

  "Serilog": {
    "MinimumLevel": {
      "Default": "Warning",
      "Override": {
        "Microsoft": "Warning",
        "System": "Warning",
        "Microsoft.AspNetCore.Authentication": "Information"
      }
    },
    // Console logger. Use Web.Config to see this.
    "WriteTo:ConsoleSublogger": {
      "Name": "Logger",
      "Args": {
        "configureLogger": {
          "WriteTo": [
            {
              "Name": "LiterateConsole",
              "Args": {
                "outputTemplate": "DevConf [{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}",
                "theme": "Code"
              }
            }
          ]
        },
        "restrictedToMinimumLevel": "Debug"
      }
    },
    "Enrich": [
      "FromLogContext",
      // Add full exception details using Serilog.Exceptions https://github.com/RehanSaeed/Serilog.Exceptions.
      "WithExceptionDetails",
      // Add the username and machine name to the logs using Serilog.Enrichers.Environment https://github.com/serilog/serilog-enrichers-environment.
      "WithEnvironmentUserName",
      "WithMachineName",
      // Add the process ID and name to the logs using Serilog.Enrichers.Process https://github.com/serilog/serilog-enrichers-process.
      "WithProcessId",
      "WithProcessName",
      // Add the current thread ID to the logs using Serilog.Enrichers.Thread https://github.com/serilog/serilog-enrichers-thread.
      "WithThreadId"
    ],
    "Properties": {
      "Application": "myapp-api"
    }
  },

0 个答案:

没有答案