private static NlogConfig ReadConfig() { var config = new NlogConfig(); config.OfXml(); return(config); }
public NlogConfigRule() { var name = NlogConfig.GetMainTraceName(); Name = name; MinLevel = "Trace"; var targetName = NlogConfig.BuildName(Name, "_"); WriteTo = $"{targetName}_log"; }
public override void WriteLine(object message) { Ticket ticket; var jce = message as Je.Exception; if (jce != null) { ticket = new Ticket { IsException = true, Text = jce.Text, Description = jce.Description }; if (string.IsNullOrWhiteSpace(ticket.Text) && string.IsNullOrWhiteSpace(ticket.Description)) { return; } TraceExtensions.WriteToFileLogger(NlogConfig.GetMainTraceName(), ticket); return; } var exception = message as Exception; if (exception != null) { var ex = new Je.Exception(exception); ticket = new Ticket { IsException = true, Text = ex.Text, Description = ex.Description }; if (string.IsNullOrWhiteSpace(ticket.Text) && string.IsNullOrWhiteSpace(ticket.Description)) { return; } TraceExtensions.WriteToFileLogger(NlogConfig.GetMainTraceName(), ticket); return; } ticket = message as Jc.Ticket; if (ticket != null) { var type = ticket.GetType(); var loggerName = type == typeof(Jc.Ticket) ? NlogConfig.GetMainTraceName() : type.Name; if (string.IsNullOrWhiteSpace(ticket.Text) && string.IsNullOrWhiteSpace(ticket.Description)) { return; } TraceExtensions.WriteToFileLogger(loggerName, ticket); return; } var text = message != null && message != DBNull.Value ? message.ToString() : null; if (!string.IsNullOrWhiteSpace(text)) { TraceExtensions.WriteToFileLogger(NlogConfig.GetMainTraceName(), new Jc.Ticket { IsException = false, Text = text, Description = text }); } }
public static void RegisterLogger(string loggerName) { if (Config.IsSaved()) { return; } loggerName = NlogConfig.ParseName(loggerName); lock (Loggers) { if (!Loggers.ContainsKey(loggerName)) { if (Config.RegisterRule(loggerName)) { Loggers.Add(loggerName, null); } } } }
public NlogConfigTarget() { var name = NlogConfig.GetMainTraceName(); var targetName = NlogConfig.BuildName(name, "_"); var fileName = NlogConfig.BuildName(name, "-"); Name = $"{targetName}_log"; Type = "File"; Encoding = "UTF-8"; Layout = "${date:format=dd.MM.yyyy HH\\:mm\\:ss} ${AppUser} ${Computer} ${WinUser} [${callsite}] (${level:uppercase=true}): ${message}. ${exception:format=ToString}"; KeepFileOpen = true; NetworkWrites = true; ConcurrentWrites = true; FileName = "${basedir}/log/" + fileName + ".$$.log"; ArchiveFileName = "${basedir}/log/" + fileName + ".{##}.log"; ArchiveEvery = "Day"; ArchiveNumbering = "Rolling"; MaxArchiveFiles = 33; }
private static Logger GetLogger(string loggerName) { loggerName = NlogConfig.ParseName(loggerName); lock (Loggers) { if (!Loggers.ContainsKey(loggerName)) { return(null); } if (!Config.IsSaved()) { Config.ToXml(); } var logger = Loggers[loggerName]; if (logger == null) { logger = LogManager.GetLogger(loggerName); Loggers[loggerName] = logger; } return(Loggers[loggerName]); } }
public override void WriteLine(string message) { TraceExtensions.WriteToFileLogger(NlogConfig.GetMainTraceName(), new Jc.Ticket { IsException = false, Text = message, Description = message }); }
public static void RegisterFileLogger(this ITraceExpander expander) { InitializeFileLogger(FileLogger); Jc.Rpc <TraceRemote> .Ge.RegisterLogger(NlogConfig.GetMainTraceName()); }