Код: Выделить всё
"Serilog": {
"Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.File" ],
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Warning",
"System": "Warning"
}
},
"WriteTo": [
{ "Name": "Console" },
{ "Name": "File",
"Args": {
"path": "C:\\NotificationSystemLogs\\log-.txt",
"rollingInterval": "Day",
"outputTemplate": "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}"
}
}
],
"Enrich": [ "FromLogContext" ],
"Properties": {
"Application": "NotificationSystem"
}
}
Код: Выделить всё
Log.Logger = new LoggerConfiguration()
.WriteTo.Console()
.CreateBootstrapLogger();
Log.Information("Starting up...");
builder.Host.UseSerilog((ctx, services, configuration) =>
new LoggerConfiguration()
.ReadFrom.Configuration(ctx.Configuration)
.ReadFrom.Services(services)
.Enrich.FromLogContext()
.CreateLogger()
);
- Manually created C:\NotificationSystemLogs and gave "Everyone" full access
- Also gave IIS APPPOOL\NotificationSystem modify permissions to the folder
- Set correct path in appsettings.json (используется двойная обратная сбоя) (IIS). < /P>
Приложение работает нормально, и я могу получить к нему доступ, но Serilog просто молча не пишет в файл. ApplicationPoolidentity - Путь папки журнала: c: \ natificationsystemlogs
Папка существует < /li>
Разрешения правильны < /li>
Нет исключения, что не добавлено < /li>
Работает локально < /li>
< /ul>
? < /p>
Подробнее здесь: https://stackoverflow.com/questions/797 ... -8-web-api
Мобильная версия