private void Registrar(NivelLog nivelLog, InformacionLog informacionLog) { LogLevel level = _mapeoNivelError[nivelLog]; var theEvent = new LogEventInfo(level, string.Empty, informacionLog.Mensaje); if (informacionLog.Excepcion != null) { var detalleError = ExceptionHandler.Instancia.RecuperarDetalleError(informacionLog.Excepcion); theEvent.Properties["DatosError"] = detalleError; } var datosAdicionales = informacionLog.DatosAdicionales; if (datosAdicionales != null) { foreach (KeyValuePair <string, object> valor in datosAdicionales) { theEvent.Properties[valor.Key] = datosAdicionales[valor.Key]; } if (!datosAdicionales.ContainsKey("EventId")) { theEvent.Properties["EventId"] = (Int16)nivelLog; } } var st = new StackTrace(); StackFrame sf = st.GetFrame(2); var declaringType = sf.GetMethod().DeclaringType; if (declaringType != null) { theEvent.Properties["Modulo"] = declaringType.Module.ScopeName; theEvent.Properties["Origen"] = string.Format("{0}.{1}", declaringType.FullName, sf.GetMethod().Name); } _logger.Log(theEvent); if (NotificacionExterna != null) { NotificacionExterna.Registrar(nivelLog, informacionLog); } }
public static void RegistrarError(Exception error, Dictionary<string, object> datosAdicionales) { var informacion = new InformacionLog { DatosAdicionales = datosAdicionales }; Int16 codigoError; string mensaje; //Registrar Mensajes if (ErrorEsFatal(error, out codigoError, out mensaje)) { informacion.Mensaje = mensaje; informacion.Excepcion = error; informacion.DatosAdicionales.Add("EventId", codigoError); CustomLogManager.Instancia.RegistrarFatal(informacion); } else { if (error is ExcepcionReglaNegocio) { informacion.Mensaje = string.Format("Regla de negocio : {0}", error.Message); CustomLogManager.Instancia.RegistrarInformacion(informacion); } else if (error is ExcepcionValidacion) { informacion.Mensaje = string.Format("Regla de Validaciòn : {0}", error.Message); CustomLogManager.Instancia.RegistrarInformacion(informacion); } else { informacion.Mensaje = "Error no controlado."; informacion.Excepcion = error; CustomLogManager.Instancia.RegistrarError(informacion); } } }
public void Registrar(NivelLog nivelLog, InformacionLog informacionLog) { Console.WriteLine(informacionLog.Excepcion.Message); }
public void RegistrarTraza(InformacionLog informacionLog) { Registrar(NivelLog.Traza, informacionLog); }
public void RegistrarInformacion(InformacionLog informacionLog) { Registrar(NivelLog.Informacion, informacionLog); }
public void RegistrarAdvertencia(InformacionLog informacionLog) { Registrar(NivelLog.Advertencia, informacionLog); }
public void RegistrarFatal(InformacionLog informacionLog) { Registrar(NivelLog.Fatal, informacionLog); }
public void RegistrarError(InformacionLog informacionLog) { Registrar(NivelLog.Error, informacionLog); }
private void Registrar(NivelLog nivelLog, InformacionLog informacionLog) { LogLevel level = _mapeoNivelError[nivelLog]; var theEvent = new LogEventInfo(level, string.Empty, informacionLog.Mensaje); if (informacionLog.Excepcion != null) { var detalleError = ExceptionHandler.Instancia.RecuperarDetalleError(informacionLog.Excepcion); theEvent.Properties["DatosError"] = detalleError; } var datosAdicionales = informacionLog.DatosAdicionales; if (datosAdicionales != null) { foreach (KeyValuePair<string, object> valor in datosAdicionales) { theEvent.Properties[valor.Key] = datosAdicionales[valor.Key]; } if (!datosAdicionales.ContainsKey("EventId")) { theEvent.Properties["EventId"] = (Int16) nivelLog; } } var st = new StackTrace(); StackFrame sf = st.GetFrame(2); var declaringType = sf.GetMethod().DeclaringType; if (declaringType != null) { theEvent.Properties["Modulo"] = declaringType.Module.ScopeName; theEvent.Properties["Origen"] = string.Format("{0}.{1}", declaringType.FullName, sf.GetMethod().Name); } _logger.Log(theEvent); if (NotificacionExterna != null) { NotificacionExterna.Registrar(nivelLog, informacionLog); } }
public void RegistrarPersonalizado(InformacionLog informacionLog) { Registrar(NivelLog.Otro, informacionLog); }
public void RegistrarTraza(InformacionLog informacionLog) { Registrar(NivelLog.Traza, informacionLog); }
public void RegistrarInformacion(InformacionLog informacionLog) { Registrar(NivelLog.Informacion, informacionLog); }
public void RegistrarAdvertencia(InformacionLog informacionLog) { Registrar(NivelLog.Advertencia, informacionLog); }
public void RegistrarFatal(InformacionLog informacionLog) { Registrar(NivelLog.Fatal, informacionLog); }
public void RegistrarError(InformacionLog informacionLog) { Registrar(NivelLog.Error, informacionLog); }
public void RegistrarPersonalizado(InformacionLog informacionLog) { Registrar(NivelLog.Otro, informacionLog); }