private static void ConfigurateDebuggerLogger(NLog.Config.LoggingConfiguration logCfg) { Debug.Assert(logCfg != null); var debuggerTarget = new NLog.Targets.OutputDebugStringTarget() { Name = "debugger", Layout = LoggingLayout }; logCfg.AddTarget("debugger", debuggerTarget); var rule = new NLog.Config.LoggingRule("*", NLog.LogLevel.Trace, debuggerTarget); logCfg.LoggingRules.Add(rule); }
private void ConfigLogger() { var config = new NLog.Config.LoggingConfiguration(); // Targets where to log to: File and Console var logfile = new NLog.Targets.FileTarget("logfile") { FileName = "file.txt" }; var logconsole = new NLog.Targets.OutputDebugStringTarget("logconsole"); // Rules for mapping loggers to targets config.AddRule(LogLevel.Info, LogLevel.Fatal, logfile); config.AddRule(LogLevel.Debug, LogLevel.Fatal, logconsole); // Apply config NLog.LogManager.Configuration = config; }
private static void SetupNLog() { var configuration = new NLog.Config.LoggingConfiguration(); var serviceLog = new NLog.Targets.FileTarget("access-manager-installer") { FileName = Path.Combine(Path.GetTempPath(), "access-manager-installer.log"), ArchiveEvery = NLog.Targets.FileArchivePeriod.Day, ArchiveNumbering = NLog.Targets.ArchiveNumberingMode.Date, MaxArchiveFiles = 7, Layout = "${longdate}|${level:uppercase=true:padding=5}|${logger}|${message}${onexception:inner=${newline}${exception:format=ToString}}" }; var debugLog = new NLog.Targets.OutputDebugStringTarget(); configuration.AddRule(NLog.LogLevel.Trace, NLog.LogLevel.Fatal, serviceLog); configuration.AddRule(NLog.LogLevel.Trace, NLog.LogLevel.Fatal, debugLog); NLog.LogManager.Configuration = configuration; }