牛耳教育十六年专注长沙java培训,是湖南最专业的长沙java培训学校。也是中国十大品牌IT教育机构,16年来总共培养了28000名软件工程师。
电话:0731-82221222

java培训课程:中用程序修改log4j的输出等级

java培训课程:中用程序修改log4j的输出等级

public static void SetLogLevel(String strAppender, String level){

        if(level == null || strAppender == null)

            return;

        

        Appender appender = Logger.getRootLogger().getAppender(strAppender);

        Level levelSet = Level.toLevel(level);

        if (levelSet != null && appender != null){

            Filter filterIt = appender.getFilter();

            

            while(filterIt != null){

                if(filterIt instanceof LevelRangeFilter){

                    LevelRangeFilter f = (LevelRangeFilter)filterIt;

                    f.setLevelMin(levelSet);

                    break;

                }

                filterIt = filterIt.getNext();

            }

            

            Logger.getRootLogger().setLevel(levelSet);

        }

    }


评论

© 牛耳教育|长沙java培训|长沙java培训学校|长沙软件培 | Powered by LOFTER