Пример #1
0
 /// <summary> Determine the logging level</summary>
 static Logger()
 {
     {
         string level = ConfigurationSettings.AppSettings["edtftp.log.level"];
         if (level != null)
         {
             globalLevel = Level.GetLevel(level);
         }
         else
         {
             globalLevel = Level.OFF;
             System.Console.Out.WriteLine("WARNING: 'edtftp.log.level' not found - logging switched off");
         }
     }
 }
Пример #2
0
        /// <summary> Determine the logging level</summary>
        static Logger()
        {
            {
                globalLevel = null;
                string level = null;
                try
                {
#if NET20
                    level = ConfigurationManager.AppSettings[LEVEL_PARAM];
#else
                    level = ConfigurationSettings.AppSettings[LEVEL_PARAM];
#endif
                }
                catch (Exception ex)
                {
                    System.Console.WriteLine("WARN: Failure reading configuration file: " + ex.Message);
                }
                if (level != null)
                {
                    // first try with the strings INFO etc
                    globalLevel = Level.GetLevel(level);
                    if (globalLevel == null)
                    {
                        try
                        {
                            // now try from the enum
                            LogLevel logLevel = (LogLevel)Enum.Parse(typeof(LogLevel), level, true);
                            globalLevel = Level.GetLevel(logLevel);
                        }
                        catch (Exception)
                        {
                        }
                    }
                }

                // if no level set, switch off
                if (globalLevel == null)
                {
                    globalLevel = Level.OFF;
                    if (level != null)
                    {
                        System.Console.Out.WriteLine("WARN: '" + LEVEL_PARAM + "' configuration property invalid. Unable to parse '" + level + "' - logging switched off");
                    }
                }
            }
        }
Пример #3
0
        static Logger()
        {
            string str = null;

            try
            {
                str = ConfigurationSettings.AppSettings[LEVEL_PARAM];
            }
            catch (Exception exception)
            {
                Console.WriteLine("WARN: Failure reading configuration file: " + exception.Message);
            }
            if (str != null)
            {
                globalLevel = Level.GetLevel(str);
                if (globalLevel == null)
                {
                    try
                    {
                        EnterpriseDT.Util.Debug.LogLevel level = (EnterpriseDT.Util.Debug.LogLevel)Enum.Parse(typeof(EnterpriseDT.Util.Debug.LogLevel), str, true);
                        globalLevel = Level.GetLevel(level);
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            if (globalLevel == null)
            {
                globalLevel = Level.OFF;
                if (str != null)
                {
                    Console.Out.WriteLine("WARN: '" + LEVEL_PARAM + "' configuration property invalid. Unable to parse '" + str + "' - logging switched off");
                }
            }
        }