public GeneradorLog(string usuario, string idIdentificador, string idIdTansaccion, string archivo)
        {
            _loggerManager  = LogManager.GetLogger(Constantes.NombrePagina);
            idIdentificador = Guid.NewGuid().ToString();
            var stackFrames  = new StackTrace().GetFrames();
            var callingframe = stackFrames.ElementAt(1);
            var method       = callingframe.GetMethod().Name;

            usuario = Convert.ToString(HttpContext.Current.Session["Usuario"]);
            MDC.Set("HostName", Environment.MachineName);
            LogicalThreadContext.Properties["Usuario"]         = usuario;
            LogicalThreadContext.Properties["Identificador"]   = idIdentificador;
            LogicalThreadContext.Properties["MethodName"]      = method;
            LogicalThreadContext.Properties["ApplicationName"] = ConfigurationManager.AppSettings["ApplicationName"];
        }
Beispiel #2
0
        public static void log(string msg, string logtype)
        {
            //lock (locker)
            {
                var stackFrames  = new StackTrace().GetFrames();
                var callingframe = stackFrames.ElementAt(2);
                var method       = callingframe.GetMethod();
                //var fn = callingframe.GetFileName() + ":" + callingframe.GetFileLineNumber().ToString();
                //fn = callingframe.ToString();
                //fn = new StackTrace().ToString();
                //fn = fn.Trim();
                //string[] locations = fn.Split(new string[] { "at " }, StringSplitOptions.RemoveEmptyEntries);
                //fn = locations[2].Trim();
                //var p1 = fn.IndexOf('(');
                //var name = fn.Substring(0, p1);
                var name = method.Name;
                ThreadContext.Properties["method"] = name;

                if (logtype == "error")
                {
                    ThreadContext.Properties["status"] = "E";
                }
                else if (logtype == "warn")
                {
                    ThreadContext.Properties["status"] = "W";
                }
                else
                {
                    ThreadContext.Properties["status"] = "I";
                }

                //if (logtype == "error")
                //    logger.Error(msg);
                //else if (logtype == "warn")
                //    logger.Warn(msg);
                //else
                //    logger.Info(msg);
                logger.Info(msg);
            }
        }