コード例 #1
0
 public static LogSetting GetSetting()
 {
     if (s_HasInit == false)
     {
         lock (s_SyncObj)
         {
             if (s_HasInit == false)
             {
                 s_LogSetting = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json", optional: true).Build().GetSection("LogSetting").Get <LogSetting>();
                 s_HasInit    = true;
             }
         }
     }
     return(s_LogSetting);
 }
コード例 #2
0
ファイル: Logger.cs プロジェクト: yangjipeng/HPMessageCenter
 private static string GetSource()
 {
     try
     {
         LogSetting s = LogSection.GetSetting();
         if (s != null)
         {
             return(s.Source);
         }
         return(string.Empty);
     }
     catch
     {
         return(string.Empty);
     }
 }
コード例 #3
0
        public static List <ILogEmitter> Create()
        {
            if (s_Emitters == null)
            {
                lock (s_SyncObj)
                {
                    if (s_Emitters == null)
                    {
                        LogSetting         s    = LogSection.GetSetting();
                        List <ILogEmitter> list = new List <ILogEmitter>();

                        if (s.Emitters != null)
                        {
                            s.Emitters.ForEach(p =>
                            {
                                ILogEmitter e;
                                switch (p.Type)
                                {
                                case "text":
                                    e = new TextEmitter();
                                    break;

                                default:
                                    Type type = Type.GetType(p.Type, true);
                                    e         = (ILogEmitter)Activator.CreateInstance(type);
                                    break;
                                }
                                e.Init(p.Parameters);
                                list.Add(e);
                            });
                        }

                        s_Emitters = list;
                    }
                }
            }
            return(s_Emitters);
        }