Beispiel #1
0
        public override void OnInitialize(ConfigsReader configs)
        {
            base.OnInitialize(configs);
            var appenderNames = configs.GetStringArray("appenders", null);

            if (appenderNames != null)
            {
                foreach (var name in appenderNames)
                {
                    var appender = AppendersManager.GetAppender(name);
                    if (appender != null)
                    {
                        _redirectAppenders.Add(appender);
                    }
                }
            }
            var catagory = configs.GetString("catagory", null);

            if (catagory != null)
            {
                _catagoryRegex = new Regex(catagory);
            }
        }
Beispiel #2
0
        public static void ConfigurateLogger(ULogger logger, string catagoryName)
        {
            if (!TryLoadDefaultConfigIfNot())
            {
                return;
            }
            var catagory = Configurator.GetCatagory(catagoryName);

            if (catagory == null)
            {
                catagory = Configurator.GetCatagory(DEFAULT_CATAGORY);
            }
            if (catagory == null)
            {
                //missing default catagory
                return;
            }
            logger.ClearAppenders();
            var level = ParseLogLevel(catagory.level);

            logger.level = level;
            if (catagory.appenders == null || catagory.appenders.Length == 0)
            {
                //default
            }
            else
            {
                foreach (var ap in catagory.appenders)
                {
                    var appender = AppendersManager.GetAppender(ap);
                    if (appender != null)
                    {
                        logger.Append(appender);
                    }
                }
            }
        }