/// <summary> /// This version works with the OpenEngS 3.0.0-Snapshot Framwork /// </summary> /// <param name="args">System Arguments</param> static void Main(string[] args) { log4net.Config.BasicConfigurator.Configure(); ILog logger = LogManager.GetLogger(typeof(ExampleDomainConnector)); string destination = "tcp://localhost.:6549"; string domainName = "example"; logger.Info("Start Example wit the domain " + domainName); IExampleDomainSoap11Binding localDomain = new ExampleDomainConnector(); IDomainFactory factory = DomainFactoryProvider.GetDomainFactoryInstance("3.0.0", destination, localDomain, EExceptionHandling.Retry); //Register the connecter on the OpenEngSB String serviceId = factory.CreateDomainService(domainName); factory.RegisterConnector(serviceId, domainName); IExampleDomainEventsSoap11Binding remotedomain = factory.getEventhandler<IExampleDomainEventsSoap11Binding>(domainName); LogEvent lEvent = new LogEvent(); lEvent.name = "Example"; lEvent.level = "DEBUG"; lEvent.message = "remoteTestEventLog"; remotedomain.raiseEvent(lEvent); logger.Info("Press enter to close the Connection"); Console.ReadKey(); factory.UnRegisterConnector(domainName); factory.DeleteDomainService(domainName); factory.StopConnection(domainName); }
public override void Log(LogEvent logEvent) { lock (_listLock) { _logEvents.Add(logEvent); } }
/// <summary> /// Emit the provided log event to the sink. /// </summary> /// <param name="logEvent">The log event to write.</param> public void Emit(LogEvent logEvent) { LogEventPropertyValue eventId; logEvent.Properties.TryGetValue("EventId", out eventId); LogEventPropertyValue hostName; logEvent.Properties.TryGetValue("Host", out hostName); LogEventPropertyValue url; logEvent.Properties.TryGetValue("RequestPath", out url); Message message = new Message(logEvent.RenderMessage(_formatProvider)) { id = eventId?.ToString(), hostname = hostName?.ToString(), url = url?.ToString(), QueryString = RequestQueryToQuery(logEvent), Severity = LevelToSeverity(logEvent), DateTime = logEvent.Timestamp.DateTime.ToUniversalTime(), Detail = logEvent.Exception?.ToString(), Data = PropertiesToData(logEvent), }; // Convert to json string messageJson = MessageToJson(message); // Call ElmhaIO HttpClient client = new HttpClient(); client.PostAsync($@"https://elmah.io/api/v2/messages?logid={_logId}", new StringContent(messageJson, Encoding.UTF8, "application/json")); }
public void Write(LogLevel level, LogEvent logEvent) { LogBuilder fluent; switch (level) { case LogLevel.Trace: fluent = _logger.Trace(); break; case LogLevel.Info: fluent = _logger.Info(); break; case LogLevel.Warning: fluent = _logger.Warn(); break; case LogLevel.Error: fluent = _logger.Error(); break; case LogLevel.Critical: fluent = _logger.Fatal(); break; default: throw new ApplicationException("Invalid log level"); } if (!string.IsNullOrWhiteSpace(logEvent.Message)) fluent.Message(logEvent.Message); if (logEvent.Exception != null) fluent.Exception(logEvent.Exception); foreach (var parameter in logEvent.Parameters) { fluent.Property(parameter.Key, parameter.Value); } fluent.Write(); }
private void WriteToFile(LogEvent logEvent) { lock (this.syncRoot) { if (this.disposed) { throw new ObjectDisposedException(ThisObjectName, "The rolling file sink has been disposed"); } var resetSequence = currentSink.LogFile.Date.Date != DateTime.UtcNow.Date; if (currentSink.EnableLevelLogging && currentSink.ActiveLogLevel != logEvent.Level) { currentSink = NextSizeLimitedFileSink(resetSequence, logEvent.Level); } if (currentSink.SizeLimitReached || resetSequence) { currentSink = NextSizeLimitedFileSink(resetSequence, logEvent.Level); ApplyRetentionPolicy(roller.LogFileDirectory); } if (this.currentSink != null) { this.currentSink.Emit(logEvent); } } }
/// <summary> /// Creates a new SmtpLogEventBuilder based on the passed log event /// </summary> /// <param name="logEvent">The log event to use as a base</param> /// <returns>A new instance of SmtpLogEventBuilder</returns> public static EmailLogEventBuilder Create(LogEvent logEvent) { return new EmailLogEventBuilder { LogEvent = logEvent }; }
// Synchronous logging public override void Log(LogEvent logEvent) { // Lock, to keep our colors from getting messed up lock (_colorLock) { // Get a hold of the current colors var oldForeground = Console.ForegroundColor; var oldBackground = Console.BackgroundColor; try { // Set the colors to our custom colors Console.BackgroundColor = BackgroundColor; Console.ForegroundColor = ForegroundColor; // Write out our message Console.Out.Write(Layout.FormatLogEvent(logEvent)); } finally { // Make sure we reset our colors Console.ForegroundColor = oldForeground; Console.BackgroundColor = oldBackground; } } }
/// <summary> /// Initializes a new instance of the <see cref="LogBatchEntry" /> class. /// </summary> /// <param name="log">The log.</param> /// <param name="message">The message.</param> /// <param name="logEvent">The log event.</param> /// <param name="extraData">The extra data.</param> public LogBatchEntry(ILog log, string message, LogEvent logEvent, object extraData) { Log = log; Message = message; LogEvent = logEvent; ExtraData = extraData; }
protected override void WriteLine(string textLine, LogEvent logEvent) { if (_activity == null) return; _activity.RunOnUiThread(() => { try { var adBuilder = new AlertDialog.Builder(_activity); adBuilder.SetTitle(string.Format("LogWriter: {0}", logEvent.Logger.LoggingType.Name)); adBuilder.SetMessage(textLine); adBuilder.SetNegativeButton("OK", (s, e) => { var alertDialog = s as AlertDialog; if (alertDialog != null) { alertDialog.Dismiss(); alertDialog.Cancel(); } }); adBuilder.Create().Show(); } catch (Exception e) { // TODO detta måste fixas // something went terribly wrong } }); }
/// <summary> /// Called when any message is written to the log. /// </summary> /// <param name="log">The log.</param> /// <param name="message">The message.</param> /// <param name="logEvent">The log event.</param> /// <param name="extraData">The additional data.</param> /// <param name="time">The time.</param> protected override void Write(ILog log, string message, LogEvent logEvent, object extraData, System.DateTime time) { base.Write(log, message, logEvent, extraData, time); switch (logEvent) { case LogEvent.Debug: _eventSource.Debug(message); break; case LogEvent.Info: _eventSource.Info(message); break; case LogEvent.Warning: _eventSource.Warning(message); break; case LogEvent.Error: _eventSource.Error(message); break; default: throw new ArgumentOutOfRangeException("logEvent"); } }
protected override void Write(ILog log, string message, LogEvent logEvent, object extraData, LogData logData, DateTime time) { if (log.TargetType != typeof(TestLogListener)) { return; } switch (logEvent) { case LogEvent.Debug: DebugCount++; break; case LogEvent.Info: InfoCount++; break; case LogEvent.Warning: WarningCount++; break; case LogEvent.Error: ErrorCount++; break; case LogEvent.Status: StatusCount++; break; } }
/// <summary> /// Called when any message is written to the log. /// </summary> /// <param name="log">The log.</param> /// <param name="message">The message.</param> /// <param name="logEvent">The log event.</param> /// <param name="extraData">The extra data.</param> protected override void Write(ILog log, string message, LogEvent logEvent, object extraData) { string consoleMessage = string.Format("{0} => [{1}] {2}", DateTime.Now.ToString("hh:mm:ss:fff"), logEvent.ToString().ToUpper(), message); #if NETFX_CORE System.Diagnostics.Debug.WriteLine(consoleMessage); #elif WINDOWS_PHONE System.Diagnostics.Debug.WriteLine(consoleMessage); #elif SL4 || SL5 if (InitializeConsole()) { _dispatcher.BeginInvoke(() => _console.InvokeSelf(consoleMessage)); } #elif NET switch (logEvent) { case LogEvent.Debug: System.Diagnostics.Trace.WriteLine(consoleMessage); break; case LogEvent.Info: System.Diagnostics.Trace.TraceInformation(consoleMessage); break; case LogEvent.Warning: System.Diagnostics.Trace.TraceWarning(consoleMessage); break; case LogEvent.Error: System.Diagnostics.Trace.TraceError(consoleMessage); break; } #endif }
public void Emit(LogEvent logEvent) { if (logEvent == null) throw new ArgumentNullException("logEvent"); lock (syncRoot) { if (disposed) { throw new ObjectDisposedException(ThisObjectName, "Cannot write to disposed file"); } if (output == null) { return; } formatter.Format(logEvent, output); output.Flush(); this.ActiveLogLevel = logEvent.Level; if (output.BaseStream.Length > fileSizeLimitBytes) { sizeLimitReached = true; } } }
// Synchronous logging public override void Log(LogEvent logEvent) { // Lock, to keep our colors from getting messed up lock (_colorLock) { // Get a hold of the current colors var oldForeground = Console.ForegroundColor; var oldBackground = Console.BackgroundColor; try { // Feedback loop prevention var silent = logEvent != null && logEvent.Silent; // Set the colors to our custom colors Console.BackgroundColor = GetConsoleColor(logEvent, BackgroundColorMeta, ColorConfig.BackgroundColor, silent); Console.ForegroundColor = GetConsoleColor(logEvent, ForegroundColorMeta, ColorConfig.ForegroundColor, silent); // Write out our message Console.Out.Write(Layout.FormatLogEvent(logEvent)); } finally { // Make sure we reset our colors Console.ForegroundColor = oldForeground; Console.BackgroundColor = oldBackground; } } }
public void Enrich(LogEvent e, out string propertyName, out object propertyValue) { var frame = new StackFrame(4); //warning! this can change after refactoring propertyName = "method"; MethodBase method = frame.GetMethod(); var sb = new StringBuilder(); sb.Append(method.DeclaringType.FullName); sb.Append("."); sb.Append(method.Name); sb.Append("("); bool isFirst = true; foreach(ParameterInfo p in method.GetParameters()) { if (!isFirst) { sb.Append(", "); } else { isFirst = false; } sb.Append(p.ParameterType.Name); sb.Append(" "); sb.Append(p.Name); } sb.Append(")"); propertyValue = sb.ToString(); }
protected override void WriteLine(string textLine, LogEvent logEvent) { if (logEvent.LogLevel == LogLevel.FatalError) { Android.Util.Log.Error(logEvent.AppName, textLine); return; } if (logEvent.LogLevel == LogLevel.Error) { Android.Util.Log.Error(logEvent.AppName, textLine); return; } if (logEvent.LogLevel == LogLevel.Warning) { Android.Util.Log.Warn(logEvent.AppName, textLine); return; } if (logEvent.LogLevel == LogLevel.Info) { Android.Util.Log.Info(logEvent.AppName, textLine); return; } if (logEvent.LogLevel == LogLevel.Debug) { Android.Util.Log.Debug(logEvent.AppName, textLine); return; } if (logEvent.LogLevel == LogLevel.Verbose) { Android.Util.Log.Verbose(logEvent.AppName, textLine); return; } }
public static void AddLogEvent(LogEvent logEvent) { if (!_activeLogEvents.Contains(logEvent)) { _activeLogEvents.Add(logEvent); } }
void LogMessage(string message, LogEvent logEvent) { if (logEvent == LogEvent.Error) { Errors.Add(message); return; } if (logEvent == LogEvent.Warning) { Warnings.Add(message); return; } if (logEvent == LogEvent.Info) { Informations.Add(message); return; } if (logEvent == LogEvent.Debug) { Debugs.Add(message); // ReSharper disable once RedundantJumpStatement return; } }
void LogEvent(LogEvent eventInfo) { if (eventInfo.Level == LogEventLevel.Verbose) { verboses.Add(eventInfo); } if (eventInfo.Level == LogEventLevel.Debug) { debugs.Add(eventInfo); } if (eventInfo.Level == LogEventLevel.Fatal) { fatals.Add(eventInfo); } if (eventInfo.Level == LogEventLevel.Error) { errors.Add(eventInfo); } if (eventInfo.Level == LogEventLevel.Information) { informations.Add(eventInfo); } if (eventInfo.Level == LogEventLevel.Warning) { warns.Add(eventInfo); } }
private static void UpdateConsoleColors(LogEvent logEvent) { var colorSet = ColorSets[logEvent]; Console.BackgroundColor = colorSet.Background; Console.ForegroundColor = colorSet.Foreground; }
public override void Log(LogEvent oEvent) { m_oEventLog.Source = this.AppName; m_oEventLog.WriteEntry(oEvent.Message, GetEventEntryType(oEvent.Level), oEvent.ID); //test exception //throw new Exception("test exp from WindowsEventHandler class"); }
public static void Log(LogEvent data) { mut.WaitOne(); var text = string.Format("[{0}] {1}\n", data.Time, data); Logging.instance.sb.Append(text); Logging.instance.events.AddLast(data); mut.ReleaseMutex(); }
/// <summary> /// Initializes a new instance of the <see cref="LogEntry" /> class. /// </summary> /// <param name="log">The log.</param> /// <param name="message">The message.</param> /// <param name="logEvent">The log event.</param> /// <param name="extraData">The extra data.</param> /// <param name="time">The time.</param> public LogEntry(ILog log, string message, LogEvent logEvent, object extraData, DateTime time) { Time = time; Log = log; Message = message; LogEvent = logEvent; ExtraData = extraData; }
/// <summary> /// Convert Serilog LogEvent query parameters to ElmahIO querystring /// </summary> /// <param name="logEvent"></param> /// <returns></returns> private static List<KeyValuePair<string, string>> RequestQueryToQuery(LogEvent logEvent) { List<KeyValuePair<string, string>> queryString = new List<KeyValuePair<string, string>>(); // TODO: Extract query parameters return queryString; }
/// <summary> /// Initializes a new instance of the <see cref="LogMessageEventArgs" /> class. /// </summary> /// <param name="log">The log.</param> /// <param name="message">The message.</param> /// <param name="extraData">The extra data.</param> /// <param name="logEvent">The log event.</param> /// <param name="time">The time.</param> public LogMessageEventArgs(ILog log, string message, object extraData, LogEvent logEvent, DateTime time) { Log = log; Time = time; Message = message; ExtraData = extraData; LogEvent = logEvent; }
protected override void Write(ILog log, string message, LogEvent logEvent, object extraData, DateTime time) { _textBox.Dispatcher.Invoke(new Action(() => { _textBox.AppendText(string.Format("{0} [{1}] {2}", time.ToString("hh:mm:ss.fff"), logEvent.ToString().ToUpper(), message)); _textBox.AppendText(Environment.NewLine); _textBox.ScrollToEnd(); })); }
/// <summary> /// Called when any message is written to the log. /// </summary> /// <param name="log">The log.</param> /// <param name="message">The message.</param> /// <param name="logEvent">The log event.</param> /// <param name="extraData">The additional data.</param> void ILogListener.Write(ILog log, string message, LogEvent logEvent, object extraData) { if (IgnoreCatelLogging && log.IsCatelLogging) { return; } Write(log, message, logEvent, extraData); }
protected override bool ShouldIgnoreLogMessage(ILog log, string message, LogEvent logEvent, object extraData, LogData logData, DateTime time) { if (message.StartsWith("Uninitialized")) { return true; } return false; }
protected override void Write(ILog log, string message, LogEvent logEvent, object extraData, LogData logData, DateTime time) { _textBox.Dispatcher.Invoke(() => { _textBox.AppendText(string.Format("{0} {1}", time.ToString("HH:mm:ss.fff"), message)); _textBox.AppendText(Environment.NewLine); _textBox.ScrollToEnd(); }); }
/// <summary> /// Writes the log event to trace /// </summary> /// <param name="logEvent">The log event to write to trace</param> public override void Log(LogEvent logEvent) { // This is a "unique" condition where "Silent" is interpreted differently; // The "Silent" flag indicates to the framework that no trace/debug information // is to be written about logging the log event. This is to prevent unwanted // "feedback loops" when using a trace listener. This is the one case where // a target is actually completely silenced by this setting. if (logEvent != null && logEvent.Silent == false) Trace.Write(Layout.FormatLogEvent(logEvent)); }
public void Emit(LogEvent logEvent) { buffer.Writer.TryWrite(logEvent); }
/// <summary> /// Default log event handler. /// </summary> /// <param name="logEvent">Log event.</param> private static void OnNext(LogEvent logEvent) { var text = $"{logEvent.Component}({logEvent.CallerInfoString}) {logEvent.Timestamp:O}: {logEvent.Message}, Properties: {logEvent.PropertiesString}"; ServiceEventSource.Current.Message(text); }
public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory) { logEvent.AddPropertyIfAbsent(logEvent.Properties.Keys.Contains("SourceContext") ? propertyFactory.CreateProperty("Source", logEvent.Properties["SourceContext"].ToString().Replace("\"", "").Split('.').Last()) : propertyFactory.CreateProperty("Source", "n/a")); }
public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory) => logEvent.AddPropertyIfAbsent(propertyFactory.CreateProperty( "Severity", LogLevelSeverityMap[logEvent.Level]));
public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory) { logEvent.AddPropertyIfAbsent( propertyFactory.CreateProperty("ThreadId", Thread.CurrentThread.ManagedThreadId, false)); }
public void LogEvent(LogEvent eventValue) { LogMessage(LogEntryType.Information, String.Format("Event: {0}", eventValue.ToString())); }
/// <summary> /// Uses the configured formatter to write the supplied <see cref="LogEvent"/> instance to the stream. /// </summary> /// <param name="logEvent">The <see cref="LogEvent"/> instance to write.</param> protected override void WriteEventInternal(LogEvent logEvent) { _LogEventFormatter.FormatToTextWriter(logEvent, _Writer); _Writer.Flush(); }
internal static IDictionary <string, object> Dictionary(this LogEvent logEvent, bool storeTimestampInUtc = false, IFormatProvider formatProvider = null) { return(ConvertToDictionary(logEvent, storeTimestampInUtc, formatProvider)); }
public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory) { logEvent.AddPropertyIfAbsent(propertyFactory.CreateProperty("AzureWebJobsType", Environment.GetEnvironmentVariable("WEBJOBS_TYPE") ?? "NO_WEBJOB")); }
/// <summary> /// Format the log event into the output. /// </summary> /// <param name="logEvent">The event to format.</param> /// <param name="output">The output.</param> public void Format(LogEvent logEvent, TextWriter output) { if (logEvent == null) { throw new ArgumentNullException("logEvent"); } if (output == null) { throw new ArgumentNullException("output"); } if (!_omitEnclosingObject) { output.Write("{"); } var delim = ""; WriteJsonProperty("Timestamp", logEvent.Timestamp, ref delim, output); WriteJsonProperty("Level", logEvent.Level, ref delim, output); WriteJsonProperty("MessageTemplate", logEvent.MessageTemplate.Text, ref delim, output); if (_renderMessage) { WriteJsonProperty("RenderedMessage", logEvent.RenderMessage(_formatProvider), ref delim, output); } if (logEvent.Exception != null) { WriteJsonProperty("Exception", logEvent.Exception, ref delim, output); } if (logEvent.Properties.Count != 0) { output.Write(",\"Properties\":{"); var precedingDelimiter = ""; foreach (var property in logEvent.Properties) { WriteJsonProperty(property.Key, property.Value, ref precedingDelimiter, output); } output.Write("}"); } var tokensWithFormat = logEvent.MessageTemplate.Tokens .OfType <PropertyToken>() .Where(pt => pt.Format != null) .GroupBy(pt => pt.PropertyName) .ToArray(); if (tokensWithFormat.Length != 0) { output.Write(",\"Renderings\":{"); var rdelim = ""; foreach (var ptoken in tokensWithFormat) { output.Write(rdelim); rdelim = ","; output.Write("\""); output.Write(ptoken.Key); output.Write("\":["); var fdelim = ""; foreach (var format in ptoken) { output.Write(fdelim); fdelim = ","; output.Write("{"); var eldelim = ""; WriteJsonProperty("Format", format.Format, ref eldelim, output); var sw = new StringWriter(); format.Render(logEvent.Properties, sw); WriteJsonProperty("Rendering", sw.ToString(), ref eldelim, output); output.Write("}"); } output.Write("]"); } output.Write("}"); } if (!_omitEnclosingObject) { output.Write("}"); output.Write(_closingDelimiter); } }
public void PushLocalToContext() { TraceIdentifiersContext c = new TraceIdentifiersContext(true, "qwe").LinkToSerilogLogContext(builder => builder.WithStartup().WithLocalIdentifiers().WithLocalIdentifier()); using (LogContext.PushProperty("anyOther", "Any1")) using (c) { var logger = CreateLogger(); logger.Item1.Information("info1"); LogEvent logEvent = logger.Item3.Single(le => le.MessageTemplate.Text == "info1"); Assert.Equal(4, logEvent.Properties.Count); Assert.Equal("Any1", logEvent.Properties["anyOther"].ToString().Trim('"')); Assert.Equal(TraceIdentifiersContext.StartupId, logEvent.Properties["correlationStartup"].ToString().Trim('"')); Assert.Equal("qwe", logEvent.Properties["correlationLocal"].ToString().Trim('"')); Assert.Equal("[\"qwe\"]", logEvent.Properties["correlationLocalAll"].ToString()); using (var c1 = c.CreateChildWithLocal(false, "c1")) { logger.Item1.Information("info2"); logEvent = logger.Item3.Single(le => le.MessageTemplate.Text == "info2"); Assert.Equal(4, logEvent.Properties.Count); Assert.Equal("Any1", logEvent.Properties["anyOther"].ToString().Trim('"')); Assert.Equal(TraceIdentifiersContext.StartupId, logEvent.Properties["correlationStartup"].ToString().Trim('"')); Assert.Equal("c1", logEvent.Properties["correlationLocal"].ToString().Trim('"')); Assert.Equal("[\"qwe\", \"c1\"]", logEvent.Properties["correlationLocalAll"].ToString()); using (c1.CreateChildWithLocal(false, "c11")) { logger.Item1.Information("info3"); logEvent = logger.Item3.Single(le => le.MessageTemplate.Text == "info3"); Assert.Equal(4, logEvent.Properties.Count); Assert.Equal("Any1", logEvent.Properties["anyOther"].ToString().Trim('"')); Assert.Equal(TraceIdentifiersContext.StartupId, logEvent.Properties["correlationStartup"].ToString().Trim('"')); Assert.Equal("c11", logEvent.Properties["correlationLocal"].ToString().Trim('"')); Assert.Equal("[\"qwe\", \"c1\", \"c11\"]", logEvent.Properties["correlationLocalAll"].ToString()); } using (c1.CreateChildWithLocal(false, "c12")) { logger.Item1.Information("info4"); logEvent = logger.Item3.Single(le => le.MessageTemplate.Text == "info4"); Assert.Equal(4, logEvent.Properties.Count); Assert.Equal("Any1", logEvent.Properties["anyOther"].ToString().Trim('"')); Assert.Equal(TraceIdentifiersContext.StartupId, logEvent.Properties["correlationStartup"].ToString().Trim('"')); Assert.Equal("c12", logEvent.Properties["correlationLocal"].ToString().Trim('"')); Assert.Equal("[\"qwe\", \"c1\", \"c12\"]", logEvent.Properties["correlationLocalAll"].ToString()); } } using (c.CreateChildWithLocal(false, "c2")) { logger.Item1.Information("info5"); logEvent = logger.Item3.Single(le => le.MessageTemplate.Text == "info5"); Assert.Equal(4, logEvent.Properties.Count); Assert.Equal("Any1", logEvent.Properties["anyOther"].ToString().Trim('"')); Assert.Equal(TraceIdentifiersContext.StartupId, logEvent.Properties["correlationStartup"].ToString().Trim('"')); Assert.Equal("c2", logEvent.Properties["correlationLocal"].ToString().Trim('"')); Assert.Equal("[\"qwe\", \"c2\"]", logEvent.Properties["correlationLocalAll"].ToString()); } logger.Item1.Information("info6"); logEvent = logger.Item3.Single(le => le.MessageTemplate.Text == "info6"); Assert.Equal(4, logEvent.Properties.Count); Assert.Equal("Any1", logEvent.Properties["anyOther"].ToString().Trim('"')); Assert.Equal(TraceIdentifiersContext.StartupId, logEvent.Properties["correlationStartup"].ToString().Trim('"')); Assert.Equal("qwe", logEvent.Properties["correlationLocal"].ToString().Trim('"')); Assert.Equal("[\"qwe\"]", logEvent.Properties["correlationLocalAll"].ToString()); } }
public void Append(LogEvent logEvent) { var thriftFlumeEvent = new ThriftFlumeEventAdapter(logEvent); _client.append(thriftFlumeEvent); }
/// <summary> /// Writes the specified message as specified log event with extra data. /// </summary> /// <param name="exception">The exception.</param> /// <param name="message">The message.</param> /// <param name="extraData">The extra data.</param> /// <param name="logEvent">The log event.</param> /// <exception cref="ArgumentNullException">The <paramref name="exception" /> is <c>null</c>.</exception> /// <exception cref="ArgumentNullException">The <paramref name="exception" /> is <c>null</c>.</exception> public void WriteWithData(Exception exception, string message, object extraData, LogEvent logEvent) { if (!LogManager.LogInfo.IsLogEventEnabled(logEvent)) { return; } Argument.IsNotNull("exception", exception); Argument.IsNotNull("message", message); WriteWithData(FormatException(exception, message), extraData, logEvent); }
public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory) => logEvent.AddPropertyIfAbsent(propertyFactory.CreateProperty("UserIdentity", @"cnsys\vachev"));
public void Emit(LogEvent logEvent) { // Do nothing }
private void Log(string message) { LogEvent?.Invoke(this, new LogEventArgs(message)); }
/// <summary> /// Determine whether a queued log event should be included in the batch. If /// an override returns false, the event will be dropped. /// </summary> /// <param name="evt"></param> /// <returns></returns> protected virtual bool CanInclude(LogEvent evt) { return(true); }
public bool IsEnabled(LogEvent logEvent) { return(true); }
public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory) { logEvent.AddOrUpdateProperty(new LogEventProperty("Context", new ScalarValue($"OutboxMessage:{_notification.Id.ToString()}"))); }
public void FireLogEvent(object source, LogEventArgs args) { LogEvent?.Invoke(source, args); }
public void Emit(LogEvent logEvent) { _formatter.Format(logEvent, _writer); }
public void Write(LogEvent logEvent) => throw new NotImplementedException();
public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory) { logEvent.AddOrUpdateProperty(new LogEventProperty("Context", new ScalarValue($"Command:{_command.Id.ToString()}"))); }
public void Emit(LogEvent logEvent) { _write(logEvent); }
public void Emit(LogEvent logEvent) { }
public override object GetValue(LogEvent logEvent, IFormatProvider formatProvider = null) => LogEventToJson(logEvent, formatProvider);
public bool IsEnabled(LogEvent logEvent) => true;
public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory) { logEvent.AddPropertyIfAbsent(propertyFactory.CreateProperty("Component", "global")); }
public void Emit(LogEvent logEvent) { _logStorage.Add(logEvent); }
/// <summary> /// Create properties from the provided log event. /// </summary> /// <param name="logEvent">The log event.</param> /// <returns>A dictionary with properties representing the log event.</returns> public static IReadOnlyDictionary <string, LogEventPropertyValue> GetOutputProperties(LogEvent logEvent) { var result = logEvent.Properties.ToDictionary(kvp => kvp.Key, kvp => kvp.Value); // "Special" output properties like Message will override any properties with the same name // when used in format strings; this doesn't affect the rendering of the message template, // which uses only the log event properties. result[MessagePropertyName] = new LogEventPropertyMessageValue(logEvent.MessageTemplate, logEvent.Properties); result[TimestampPropertyName] = new ScalarValue(logEvent.Timestamp); result[LevelPropertyName] = new ScalarValue(logEvent.Level); result[NewLinePropertyName] = new ScalarValue(Environment.NewLine); var exception = logEvent.Exception == null ? "" : (logEvent.Exception + Environment.NewLine); result[ExceptionPropertyName] = new ScalarValue(exception); return(result); }