日志测试

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package com.gxsfdx.study.ex;

import java.util.logging.ConsoleHandler;
import java.util.logging.Logger;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class {
private Logger logger;

public void init(){

logger=Logger.getLogger("log");
}

@After
public void destory(){
logger=null;
}

@Test
public void testHello() {// 写到日志中

for(int i=0;i<10000;i++){
logger.finest("FINEST-test!");//Log a FINEST message
logger.info("INFO-tests!");//Log an INFO message
}
}

@Test
public void testReflect() throws Exception{//反射
String str="java.util.logging.ConsoleHandler";
Class clazz=Class.forName(str);
ConsoleHandler ch=(ConsoleHandler) clazz.newInstance();//使用的是无参构造函数创建对象
}

}

limaodeng

scribble