Пример #1
0
        /// <summary>
        /// Escribe en el log a traves de una excepcion
        /// </summary>
        /// <param name="ex">Exception</param>
        public static void WriteLog(Exception ex)
        {
            try
            {
                CreateTrace Log = new CreateTrace();
                if (Settings.Default.Exception == true)
                {
                    //using (StreamWriter w = File.AppendText(Log.fileName))
                    //{
                    string EscribirEXCEPCION = "";
                    EscribirEXCEPCION = "-------------------------------------------------------------------------------- [EXCEPCION]" + System.Environment.NewLine;
                    EscribirEXCEPCION = EscribirEXCEPCION + DateTime.Now.ToString(Formato) + " [EXCEPCION]  :" + Log.DatosInvocacion + System.Environment.NewLine;
                    EscribirEXCEPCION = EscribirEXCEPCION + "Message       : " + ex.Message + System.Environment.NewLine;
                    EscribirEXCEPCION = EscribirEXCEPCION + "Source        : " + ex.Source + System.Environment.NewLine;
                    EscribirEXCEPCION = EscribirEXCEPCION + "TargetSite    : " + ex.TargetSite + System.Environment.NewLine;
                    EscribirEXCEPCION = EscribirEXCEPCION + "StackTrace    :" + ex.StackTrace + System.Environment.NewLine;
                    EscribirEXCEPCION = EscribirEXCEPCION + "InnerException: " + ex.InnerException + System.Environment.NewLine;
                    EscribirEXCEPCION = EscribirEXCEPCION + "--------------------------------------------------------------------------------";

                    escribir(EscribirEXCEPCION, Log.fileName);
                    //escribir("-------------------------------------------------------------------------------- [EXCEPCION]", Log.fileName);
                    //escribir(DateTime.Now.ToString(Formato) + " [EXCEPCION]  :" + Log.DatosInvocacion, Log.fileName);
                    //escribir("Message       : " + ex.Message, Log.fileName);
                    //escribir("Source        : " + ex.Source, Log.fileName);
                    //escribir("TargetSite    : " + ex.TargetSite, Log.fileName);
                    //escribir("StackTrace    :" + ex.StackTrace, Log.fileName);
                    //escribir("InnerException: " + ex.InnerException, Log.fileName);
                    //escribir("--------------------------------------------------------------------------------", Log.fileName);
                    //}
                }
            }
            catch { }
        }
Пример #2
0
        /// <summary>
        /// Escribe en el log a traves de un string
        /// </summary>
        /// <param name="logText">Texto a ser guardado en el log</param>
        public static void WriteLog(LogLevel loglevel, string logText)
        {
            CreateTrace Log = new CreateTrace();

            switch (loglevel)
            {
            case LogLevel.Debug:
                if (Settings.Default.Debug == true)
                {
                    escribir(DateTime.Now.ToString(Formato) + " [" + loglevel + "]      :" + Log.DatosInvocacion + logText, Log.fileName);
                }
                break;

            case LogLevel.Information:
                if (Settings.Default.Information == true)
                {
                    escribir(DateTime.Now.ToString(Formato) + " [" + loglevel + "]:" + Log.DatosInvocacion + logText, Log.fileName);
                }
                break;

            case LogLevel.Warning:
                if (Settings.Default.Warning == true)
                {
                    escribir(DateTime.Now.ToString(Formato) + " [" + loglevel + "]    :" + Log.DatosInvocacion + logText, Log.fileName);
                }
                break;

            case LogLevel.Error:
                if (Settings.Default.Error == true)
                {
                    escribir(DateTime.Now.ToString(Formato) + " [" + loglevel + "]      :" + Log.DatosInvocacion + logText, Log.fileName);
                }
                break;

            case LogLevel.Fatal:
                if (Settings.Default.Fatal == true)
                {
                    escribir(DateTime.Now.ToString(Formato) + " [" + loglevel + "]      :" + Log.DatosInvocacion + logText, Log.fileName);
                }
                break;

            default:
                if (Settings.Default.Information == true)
                {
                    escribir(DateTime.Now.ToString(Formato) + " - [" + loglevel + "]: " + Log.DatosInvocacion + logText, Log.fileName);
                }
                break;
            }
        }
Пример #3
0
        public static void ImprimirParametro(string procedureName, IList <SqlParameter> parameters)
        {
            CreateTrace Log = new CreateTrace();

            if (Settings.Default.Information == true)
            {
                string cadena = "[" + procedureName + "] ";
                if (parameters != null)
                {
                    for (int i = 0; i < parameters.Count; i++)
                    {
                        cadena = cadena + "[" + parameters[i].ParameterName + "|" + parameters[i].Value + "]";
                    }

                    escribir(DateTime.Now.ToString(Formato) + " [" + LogLevel.Information + "]:" + Log.DatosInvocacion + cadena, Log.fileName);
                }
            }
        }