5

I have an ASP.Net Core (.Net Core 1.1.1) application, which using built-in logger and Serilog.Extensions.Logging.File for writing the log to file, it works well on my macOS development environment but CentOS environment.

The appsetting json:

"Logging": {
    "IncludeScopes": false,
    "PathFormat": "Logs/log-{Date}.log",
    "RetainedFileCountLimit": 7,
    "LogLevel": {
        "Default": "Warning"
    }
}

Startup.cs:

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) {
        loggerFactory
            .AddConsole(Configuration.GetSection("Logging"))
            .AddFile(Configuration.GetSection("Logging"))
            .AddDebug();

The Logs directory not exists, I have check following:

  • application folder owner is centos
  • application services User is centos, same as folder owner
  • logs is available on journalctl
  • no error message

Am I missing something?

Rex Lam
  • 1,385
  • 1
  • 15
  • 23
  • Do you have an appSettings.prod.json as an example that could be overwriting the logging node to have a higher logging level? You might need to set the Environment variables on the CentOS machine. – MindingData Apr 02 '17 at 22:13
  • No higher level config file. Finally, I figure out that absolute path is working fine, so I created a folder on /var/log and `chown` to centos and point the log path to that folder. – Rex Lam Apr 02 '17 at 22:58

0 Answers0