I have the following code:
var logFilePath = Path.Combine("\"%ProgramData%\\LogFiles\\Platform\\Tool\\\"", "config_tool.log");
// Default logging: Windows event log + console
var defaultLoggerConfig = new LoggerConfiguration()
.WriteTo.EventLog("Configuration Tool", manageEventSource: true)
.WriteTo.Console(LogEventLevel.Information, outputTemplate: "{Message:lj}{NewLine}{Exception}")
.WriteTo.File(path: logFilePath, LogEventLevel.Information, encoding: Encoding.UTF8, outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zz} [{Level:u3}] {Message}{NewLine}{Exception}");
Log.Logger = defaultLoggerConfig.CreateLogger();
Log.Logger.Write(LogEventLevel.Information, $"{Constants.Common.AppName} ({AppVersion})");
There is no log file created. What am I doing wrong?
Get ProgramData folder and then create your path: