diff --git a/DigitalData.Gateway.csproj b/DigitalData.Gateway.csproj index fe6f447..4540eb7 100644 --- a/DigitalData.Gateway.csproj +++ b/DigitalData.Gateway.csproj @@ -10,6 +10,9 @@ + + + diff --git a/Program.cs b/Program.cs index 9d863f1..9527f99 100644 --- a/Program.cs +++ b/Program.cs @@ -1,6 +1,11 @@ +using NLog; +using NLog.Web; using Ocelot.DependencyInjection; using Ocelot.Middleware; +var logger = LogManager.Setup().LoadConfigurationFromAppSettings().GetCurrentClassLogger(); +logger.Info("Logging initialized."); + var builder = WebApplication.CreateBuilder(args); // Make sure to add the Ocelot configuration file diff --git a/appsettings.json b/appsettings.json index 10f68b8..e8a68e1 100644 --- a/appsettings.json +++ b/appsettings.json @@ -5,5 +5,48 @@ "Microsoft.AspNetCore": "Warning" } }, - "AllowedHosts": "*" + "AllowedHosts": "*", + "NLog": { + "throwConfigExceptions": true, + "variables": { + "logDirectory": "E:\\LogFiles\\Digital Data\\workFlow.Gateway", + "logFileNamePrefix": "${shortdate}-workFlow.Gateway" + }, + "targets": { + "infoLogs": { + "type": "File", + "fileName": "${logDirectory}\\${logFileNamePrefix}-Info.log", + "maxArchiveDays": 30 + }, + "errorLogs": { + "type": "File", + "fileName": "${logDirectory}\\${logFileNamePrefix}-Error.log", + "maxArchiveDays": 30 + }, + "criticalLogs": { + "type": "File", + "fileName": "${logDirectory}\\${logFileNamePrefix}-Critical.log", + "maxArchiveDays": 30 + } + }, + // Trace, Debug, Info, Warn, Error and *Fatal* + "rules": [ + { + "logger": "*", + "minLevel": "Info", + "maxLevel": "Warn", + "writeTo": "infoLogs" + }, + { + "logger": "*", + "level": "Error", + "writeTo": "errorLogs" + }, + { + "logger": "*", + "level": "Fatal", + "writeTo": "criticalLogs" + } + ] + } }