示例#1
0
文件: LogNet.cs 项目: berczeck/.Net
        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);
            }
        }
示例#2
0
        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);
                }
            }
        }
示例#3
0
 public void Registrar(NivelLog nivelLog, InformacionLog informacionLog)
 {
     Console.WriteLine(informacionLog.Excepcion.Message);
 }
示例#4
0
文件: LogNet.cs 项目: berczeck/.Net
 public void RegistrarTraza(InformacionLog informacionLog)
 {
     Registrar(NivelLog.Traza, informacionLog);
 }
示例#5
0
文件: LogNet.cs 项目: berczeck/.Net
 public void RegistrarInformacion(InformacionLog informacionLog)
 {
     Registrar(NivelLog.Informacion, informacionLog);
 }
示例#6
0
文件: LogNet.cs 项目: berczeck/.Net
 public void RegistrarAdvertencia(InformacionLog informacionLog)
 {
     Registrar(NivelLog.Advertencia, informacionLog);
 }
示例#7
0
文件: LogNet.cs 项目: berczeck/.Net
 public void RegistrarFatal(InformacionLog informacionLog)
 {
     Registrar(NivelLog.Fatal, informacionLog);
 }
示例#8
0
文件: LogNet.cs 项目: berczeck/.Net
 public void RegistrarError(InformacionLog informacionLog)
 {
     Registrar(NivelLog.Error, informacionLog);
 }
示例#9
0
文件: LogNet.cs 项目: berczeck/.Net
        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);
            }
        }
示例#10
0
文件: LogNet.cs 项目: berczeck/.Net
 public void RegistrarPersonalizado(InformacionLog informacionLog)
 {
     Registrar(NivelLog.Otro, informacionLog);
 }
示例#11
0
文件: LogNet.cs 项目: berczeck/.Net
 public void RegistrarTraza(InformacionLog informacionLog)
 {
     Registrar(NivelLog.Traza, informacionLog);
 }
示例#12
0
文件: LogNet.cs 项目: berczeck/.Net
 public void RegistrarInformacion(InformacionLog informacionLog)
 {
     Registrar(NivelLog.Informacion, informacionLog);
 }
示例#13
0
文件: LogNet.cs 项目: berczeck/.Net
 public void RegistrarAdvertencia(InformacionLog informacionLog)
 {
     Registrar(NivelLog.Advertencia, informacionLog);
 }
示例#14
0
文件: LogNet.cs 项目: berczeck/.Net
 public void RegistrarFatal(InformacionLog informacionLog)
 {
     Registrar(NivelLog.Fatal, informacionLog);
 }
示例#15
0
文件: LogNet.cs 项目: berczeck/.Net
 public void RegistrarError(InformacionLog informacionLog)
 {
     Registrar(NivelLog.Error, informacionLog);
 }
示例#16
0
文件: LogNet.cs 项目: berczeck/.Net
 public void RegistrarPersonalizado(InformacionLog informacionLog)
 {
     Registrar(NivelLog.Otro, informacionLog);
 }