欧美三区_成人在线免费观看视频_欧美极品少妇xxxxⅹ免费视频_a级毛片免费播放_鲁一鲁中文字幕久久_亚洲一级特黄

java*工程 slf4j+logback實現日志記錄

系統 1837 0

1.目錄結構
java*工程 slf4j+logback實現日志記錄

2.java測試碼
    package com.test.main;     
     
import java.net.URL;

import org.slf4j.ILoggerFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.io.ClassPathResource;

import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.joran.JoranConfigurator;

     
public final class Boot {     
  
    /**
     * @param args
     * @throws Exception
     */
    public static void main(String[] args) throws Exception{     
    	Logger logger = LoggerFactory.getLogger(Boot.class);
    	//從web.xml讀配置
        ApplicationContext ctx = new ClassPathXmlApplicationContext("config/applicationContext.xml");     
       // A a = (A) ctx.getBean("a");     
       // a.sayHello();     
        EntityTestTwo a = (EntityTestTwo)ctx.getBean("entityTwo"); 
        //SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-ss");
        //a.setBeginDate(new Date());
       // a.setSex(222);
        a.setTel("11111111111");
       
        //logger.
        //String path = System.getProperty("user.dir");
        //BasicConfigurator.configure();
       // PropertyConfigurator.configure(new ClassPathResource("config/logback.properties").getURL()); 
       // System.out.println(new ClassPathResource("config/logback.properties").getURL());
        String logbackCfg = "config/logback.xml";   
        URL logURL = new ClassPathResource(logbackCfg).getURL();   
        System.out.println(logURL);
        ILoggerFactory loggerFactory = LoggerFactory.getILoggerFactory();   
        LoggerContext loggerContext = (LoggerContext) loggerFactory;   
        //loggerContext.reset();   
        JoranConfigurator configurator = new JoranConfigurator();   
        configurator.setContext(loggerContext);   
        configurator.doConfigure(logURL);
        logger.debug("dddd");
        logger.info("wowowow");
        logger.error("yanzhengosss");
       // PropertyConfigurator.configure("/config/log4j.properties");
       
        //B b = (B) ctx.getBean("b");     
        //b.sayHi();  
        
        //
        /*String className="com.test.main.EntityTest";
        Class test = null;
		try {
			test = Class.forName(className);
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        Method[] methods = test.getMethods();
        Set<Method> set = new HashSet<Method>(); 
        for(int i=0;i<methods.length;i++) 
        { 
        	boolean otherFlag = methods[i].isAnnotationPresent(AnotationTest.class); 
        	if(otherFlag) set.add(methods[i]); 
      	} 
      	for(Method m: set) 
      	{ 
      		AnotationTest anotationTest = m.getAnnotation(AnotationTest.class); 
      		System.out.println(anotationTest.regExp()); 
      		System.out.println("創建的社區:"+anotationTest.ifTip());
      	}*/
    }     
     
}
  

3.配置文件
    <?xml version="1.0" encoding="UTF-8" ?> 
<configuration>
  <Property name="log.base" value="./logs/anttesttools" /> 
 <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
  <File>${log.base}.log</File> 
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
  <FileNamePattern>${log.base}.%i.log</FileNamePattern> 
  <MinIndex>1</MinIndex> 
  <MaxIndex>5</MaxIndex> 
  </rollingPolicy>
 <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
  <MaxFileSize>5MB</MaxFileSize> 
  </triggeringPolicy>
 <layout class="ch.qos.logback.classic.PatternLayout">
  <Pattern>%date [%thread] %-5level %logger{80} - %msg%n</Pattern> 
  </layout>
  </appender>
  <logger name="anttesttools" level="debug" /> 
 <root level="debug">
  <appender-ref ref="FILE" /> 
  </root>
  </configuration>
  

4.日志輸出
    2009-11-22 17:27:57,192 [main] ERROR com.test.main.Boot - yanzhengosss
2009-11-22 17:30:16,470 [main] DEBUG com.test.main.Boot - dddd
2009-11-22 17:30:16,470 [main] INFO  com.test.main.Boot - wowowow
2009-11-22 17:30:16,470 [main] ERROR com.test.main.Boot - yanzhengosss
2009-11-22 17:37:58,262 [main] DEBUG com.test.main.Boot - dddd
2009-11-22 17:37:58,278 [main] INFO  com.test.main.Boot - wowowow
2009-11-22 17:37:58,278 [main] ERROR com.test.main.Boot - yanzhengosss
2009-11-22 17:38:15,049 [main] DEBUG com.test.main.Boot - dddd
2009-11-22 17:38:15,064 [main] INFO  com.test.main.Boot - wowowow
2009-11-22 17:38:15,064 [main] ERROR com.test.main.Boot - yanzhengosss
2009-11-22 17:43:37,366 [main] DEBUG com.test.main.Boot - dddd
2009-11-22 17:43:37,366 [main] INFO  com.test.main.Boot - wowowow
2009-11-22 17:43:37,366 [main] ERROR com.test.main.Boot - yanzhengosss
2009-11-22 17:44:09,270 [main] DEBUG com.test.main.Boot - dddd
2009-11-22 17:44:09,270 [main] INFO  com.test.main.Boot - wowowow
2009-11-22 17:44:09,286 [main] ERROR com.test.main.Boot - yanzhengosss
2009-11-22 17:44:58,741 [main] DEBUG com.test.main.Boot - dddd
2009-11-22 17:44:58,741 [main] INFO  com.test.main.Boot - wowowow
2009-11-22 17:44:58,741 [main] ERROR com.test.main.Boot - yanzhengosss
2009-11-22 18:26:29,220 [main] DEBUG com.test.main.Boot - dddd
2009-11-22 18:26:29,236 [main] INFO  com.test.main.Boot - wowowow
2009-11-22 18:26:29,236 [main] ERROR com.test.main.Boot - yanzhengosss

  

java*工程 slf4j+logback實現日志記錄


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 免费一区二区三区 | 久久aⅴ国产欧美74aaa | 亚洲永久精品国产 | 国产精品三级国语在线看 | 精品国产免费一区二区三区 | 亚洲一区二区三区在线 | 伦理午夜电影免费观看 | 亚洲美女一区二区三区 | 精品一区亚洲 | 国产亚洲欧美在线视频 | 污视频在线免费播放 | 成年网站在线观看 | 成人亚洲一区二区色情无码潘金莲 | 日本在线亚州精品视频在线 | 国产综合亚洲精品一区二 | 久久99精品久久久久久琪琪 | 色视频在线免费观看 | 免费毛片在线播放 | 成人福利短视频 | 国产精品网址在线观看你懂的 | 国产精品视频网 | 噜噜噜噜狠狠狠7777视频 | 久久久看 | 二区三区偷拍浴室洗澡视频 | 国产精品久久久久久久网站 | 国产精品中文字幕在线 | 亚洲精品在线免费 | 夜精品A片观看无码一区二区 | 免费观看欧美一级高清 | 奇米影视亚洲精品一区 | 中文字幕精品一区二区三区精品 | 色综合天天射 | h片在线看 | 免费观看一区二区三区毛片 | 国产成人高潮免费观看精品 | 亚洲综合色视频在线观看 | 君岛美绪一区二区三区 | 深夜你懂的在线网址入口 | 免费一区二区三区免费视频 | 九九香蕉视频 | 欧美视频亚洲视频 |