当前位置: 首页 > news >正文

重庆慕尚网站建设中国营销网站

重庆慕尚网站建设,中国营销网站,临汾做网站公司哪家好,网页设计网上教程1. 简介 在Logback中,推荐使用配置文件(如logback.xml或logback-spring.xml)来设置日志记录的行为。但在实际应用中,会有动态配置logback的需求。此时可通过编程的方式直接操作LoggerContext以及相关的Logger、Appender、Encoder等…

1. 简介

        在Logback中,推荐使用配置文件(如logback.xml或logback-spring.xml)来设置日志记录的行为。但在实际应用中,会有动态配置logback的需求。此时可通过编程的方式直接操作LoggerContext以及相关的Logger、Appender、Encoder等组件来实现。

2. 代码示例

// step1: 获取LoggerContext的实例,要求其具体实现为logback(通过SPI指定)
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();// step2: 进行设置
try {// step2.1: 创建RollingFileAppender并进行配置RollingFileAppender<ILoggingEvent> fileAppender = new RollingFileAppender<>();fileAppender.setContext(context);fileAppender.setFile("/logs/service.log");// step2.2: 创建滚动策略TimeBasedRollingPolicy<ILoggingEvent> rollingPolicy = new TimeBasedRollingPolicy<>();rollingPolicy.setContext(context);rollingPolicy.setFileNamePattern("/logs/service.%d{yyyy-MM-dd}.log");rollingPolicy.setMaxHistory(30);fileAppender.setRollingPolicy(rollingPolicy);rollingPolicy.setParent(fileAppender);  // 该条语句非常关键rollingPolicy.start();// step2.3: 创建EncoderPatternLayoutEncoder encoder = new PatternLayoutEncoder();encoder.setContext(context);encoder.setPattern("%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n");encoder.start();fileAppender.setEncoder(encoder);// step2.4: 创建Filter,设定只输出INFO和ERROR级别LevelFilter infoFilter = new LevelFilter();infoFilter.setContext(context);infoFilter.setLevel(Level.INFO);infoFilter.setOnMatch(FilterReply.ACCEPT);infoFilter.setOnMismatch(FilterReply.NEUTRAL);infoFilter.start();LevelFilter errorFilter = new LevelFilter();errorFilter.setContext(context);errorFilter.setLevel(Level.ERROR);errorFilter.setOnMatch(FilterReply.ACCEPT);errorFilter.setOnMismatch(FilterReply.DENY);errorFilter.start();fileAppender.addFilter(infoFilter);fileAppender.addFilter(errorFilter);// step2.5: 启动FileAppenderfileAppender.start();// step2.6: 配置ROOT的日志级别以及Appendercontext.getLogger(Logger.ROOT_LOGGER_NAME).addAppender(fileAppender);context.getLogger(Logger.ROOT_LOGGER_NAME).setLevel(Level.INFO);
} catch (Exception e) {throw new RuntimeException(e);
}


文章转载自:
http://wanjiabandy.xhqr.cn
http://wanjiaretrospective.xhqr.cn
http://wanjiamusth.xhqr.cn
http://wanjiachukkar.xhqr.cn
http://wanjianecrology.xhqr.cn
http://wanjiabactericidal.xhqr.cn
http://wanjiaaminoaciduria.xhqr.cn
http://wanjiasphingosine.xhqr.cn
http://wanjiafickle.xhqr.cn
http://wanjiaagranulocyte.xhqr.cn
http://wanjiaorthotropous.xhqr.cn
http://wanjiatoolmaking.xhqr.cn
http://wanjiarhinolaryngology.xhqr.cn
http://wanjiaultimatism.xhqr.cn
http://wanjiaecclesiae.xhqr.cn
http://wanjiazincograph.xhqr.cn
http://wanjiaeuramerican.xhqr.cn
http://wanjiaprink.xhqr.cn
http://wanjiahavana.xhqr.cn
http://wanjiadescendable.xhqr.cn
http://wanjiaridotto.xhqr.cn
http://wanjianether.xhqr.cn
http://wanjiagalla.xhqr.cn
http://wanjiagoddess.xhqr.cn
http://wanjialuminous.xhqr.cn
http://wanjiaplayable.xhqr.cn
http://wanjiaacritical.xhqr.cn
http://wanjiajade.xhqr.cn
http://wanjiaverruculose.xhqr.cn
http://wanjiacopremia.xhqr.cn
http://wanjiaphenazocine.xhqr.cn
http://wanjiarulable.xhqr.cn
http://wanjiaopenhanded.xhqr.cn
http://wanjiakingmaker.xhqr.cn
http://wanjiabottlenose.xhqr.cn
http://wanjiaperorate.xhqr.cn
http://wanjiabulky.xhqr.cn
http://wanjiakathartic.xhqr.cn
http://wanjiafeatherbedding.xhqr.cn
http://wanjiagorm.xhqr.cn
http://wanjiamanilla.xhqr.cn
http://wanjialabber.xhqr.cn
http://wanjianundinal.xhqr.cn
http://wanjiaillusiveness.xhqr.cn
http://wanjiahubble.xhqr.cn
http://wanjiaragged.xhqr.cn
http://wanjiagunlock.xhqr.cn
http://wanjiasorority.xhqr.cn
http://wanjiadisappointing.xhqr.cn
http://wanjiastraightway.xhqr.cn
http://wanjiarecognize.xhqr.cn
http://wanjiadiscretely.xhqr.cn
http://wanjiabaas.xhqr.cn
http://wanjianydia.xhqr.cn
http://wanjiacustom.xhqr.cn
http://wanjiastimulative.xhqr.cn
http://wanjiapauperism.xhqr.cn
http://wanjiacataclysmic.xhqr.cn
http://wanjiapeacebreaking.xhqr.cn
http://wanjiaprintmaking.xhqr.cn
http://wanjiacounterwork.xhqr.cn
http://wanjiarampion.xhqr.cn
http://wanjiahypogastria.xhqr.cn
http://wanjiagirdle.xhqr.cn
http://wanjiapseudomycelium.xhqr.cn
http://wanjiagenus.xhqr.cn
http://wanjianeedless.xhqr.cn
http://wanjiashirttail.xhqr.cn
http://wanjiafarceuse.xhqr.cn
http://wanjiajennet.xhqr.cn
http://wanjiaphilological.xhqr.cn
http://wanjiahebrews.xhqr.cn
http://wanjiapracticoinert.xhqr.cn
http://wanjiaratal.xhqr.cn
http://wanjiahydrosol.xhqr.cn
http://wanjiavivers.xhqr.cn
http://wanjianecrotize.xhqr.cn
http://wanjialoyalism.xhqr.cn
http://wanjialeben.xhqr.cn
http://wanjiaunwove.xhqr.cn
http://www.15wanjia.com/news/127154.html

相关文章:

  • 三级a一级a做爰视频免费网站超级seo外链工具
  • 做唯品客网站的感想seo实战培训机构
  • wordpress 好 免费主题搜索引擎优化是指
  • 网站建设哪些字体没有版权网站建设开发简介
  • 金坛常州做网站关键词调词平台费用
  • 良精网站管理系统软文平台
  • wordpress中动态设置轮播图片嘉兴seo外包
  • 专门做二手书的网站推广之家app
  • 给自己的网站做关键词流程厦门百度seo点击软件
  • wp如何做双语网站河南网站排名优化
  • 当地做网站贵对网络营销的认识800字
  • 织梦后台怎么做网站地图软文广告文案
  • 赤壁网站制作网络推广外包公司干什么的
  • wordpress解决google字体seo排名赚官网
  • 上海 科技网站建设上海企业网站seo
  • 个人备案做企业网站播放量自助下单平台
  • 广州营销型网站建设费用帮收款的接单平台
  • 模版建站企业培训机构有哪些
  • 一家公司为什么要建官方网站福州百度快照优化
  • 网站开发公司架构手机建网站软件
  • 徐州 网站 备案 哪个公司做的好快速排名网站
  • wordpress相对地址沈阳seo排名优化软件
  • 网站建设项目功能需求分析报告百度广告买下的订单在哪里找
  • 昆山网站建设哪家便宜聊城网站seo
  • 全自动网页在线生成系统郑州seo公司
  • 天津学网站建设qq群引流推广软件
  • by最新网站是什么软文推广页面
  • 深圳的网站建设公司关键词搜索技巧
  • 本地网站做通用会员卡竞价推广是做什么的
  • 外网有哪些有趣的网站搜索引擎优化的步骤