private static string AddLoggingToArgsForSchedule(string args, ScheduledTaskTypeEnum scheduledTaskType) { string appDir = Path.GetDirectoryName(Properties.Settings.Default.ConfigFileLocation); string logDir = Properties.Settings.Default.LogFileDirectory; string logFilename = $"<DATETIME> {scheduledTaskType.ToString().ToLower()}.log"; // the powershell script will replace <DATETIME> string newArgs = $@"--log ""{appDir}\{logDir}\{logFilename}"" {args}"; return(newArgs); }
private static string AddLoggingToArgsForSchedule(string args, ScheduledTaskTypeEnum scheduledTaskType) { FileTarget fileTarget = (FileTarget)LogManager.Configuration.FindTargetByName("file"); // Need to set timestamp here if filename uses date. // For example - filename="${basedir}/logs/${shortdate}/trace.log" LogEventInfo logEventInfo = new LogEventInfo { TimeStamp = DateTime.Now }; string fileName = fileTarget.FileName.Render(logEventInfo); string logDir = Path.GetDirectoryName(fileName); string logFilename = $"<DATETIME> {scheduledTaskType.ToString().ToLower()}.log"; // the powershell script will replace <DATETIME> string newArgs = $@"--log ""{logDir}\{logFilename}"" {args}"; return(newArgs); }