private void Log(DiagnosticsAggregationEvent evt, uint?sessionId, TimeSpan?duration, string clientHostName, string clientProcessName, int?clientProcessId, string serverHostName, string description) { if (!this.loggingEnabled) { return; } LogSchema logSchema = DiagnosticsAggregationLog.schema; uint? num = sessionId; DiagnosticsAggregationLogRow row = new DiagnosticsAggregationLogRow(logSchema, evt, (num != null) ? new long?((long)((ulong)num.GetValueOrDefault())) : null, duration, clientHostName, clientProcessName, clientProcessId, serverHostName, description); try { lock (this) { if (this.loggingEnabled) { this.log.Append(row, 0); } } } catch (ObjectDisposedException) { ExTraceGlobals.DiagnosticsAggregationTracer.TraceError(0L, "Appending to Diagnostics Aggregation log failed with ObjectDisposedException"); } }
public DiagnosticsAggregationLogRow(LogSchema schema, DiagnosticsAggregationEvent evt, long?sessionId, TimeSpan?duration, string clientHostName, string clientProcessName, int?clientProcessId, string serverHostName, string description) : base(schema) { base[1] = Environment.MachineName; base[2] = ((sessionId != null) ? sessionId.ToString() : string.Empty); base[3] = evt; base[4] = ((duration != null) ? duration.ToString() : string.Empty); base[5] = clientHostName; base[6] = clientProcessName; base[7] = ((clientProcessId != null) ? clientProcessId.ToString() : string.Empty); base[8] = serverHostName; base[9] = description; }
static LogSchema GetFakeLogEntry() { var log = new LogSchema { Errnum = Faker.NumberFaker.Number(0, 10), Index = count++, Timeval = Faker.NumberFaker.Number(0, 65000), Supdat = GetFakeEvent() }; log.Errdesc = log.Supdat.GetType().Name; return(log); }
/// <summary> /// This is customize implementation of default Exception Logger /// </summary> /// <param name="context"></param> /// <param name="cancellationToken"></param> /// <returns></returns> public async Task LogAsync(ExceptionLoggerContext context, System.Threading.CancellationToken cancellationToken) { var logSchema = new LogSchema(); logSchema.Exception = context.Exception; logSchema.Message = context.Exception.Message; if (context.ExceptionContext != null && context.ExceptionContext.ControllerContext != null && context.ExceptionContext.ControllerContext.ControllerDescriptor != null) { logSchema.ControllerName = context.ExceptionContext.ControllerContext.ControllerDescriptor.ControllerName ?? string.Empty; var actionContext = ((System.Web.Http.ApiController)context.ExceptionContext.ControllerContext.Controller).ActionContext; if (actionContext != null && actionContext.ActionDescriptor != null) { logSchema.MethodName = actionContext.ActionDescriptor.ActionName; } logSchema.EventId = 1; logSchema.MessageId = 1;//set based on exception type; } await logger.LogAsync(logSchema); }
public LogSchema GetAlert() { return(LogSchema.FromJson(this.JSON)); }