-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogTest.java
More file actions
41 lines (30 loc) · 1.62 KB
/
LogTest.java
File metadata and controls
41 lines (30 loc) · 1.62 KB
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
40
41
package Chapter11Throwable;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.Logger;
public class LogTest {
private static final Logger myLogger=Logger.getLogger("com.mycompany.myapp");
public static void main(String[] args) throws IOException {
//ȡ��������־-------Level.OFFʵ�����ǹر������м������־��¼
//Logger.getGlobal().setLevel(Level.OFF);
myLogger.setLevel(Level.FINE);
Logger.getGlobal().info("Log Begin");
myLogger.warning("warning �������־����¼");
//Ĭ��ֻ���¼INFO��Warning��severe�����������־��----��Ҫ��¼�����������־����Ҫ�ı���־������������
myLogger.log(Level.FINE, "FINE �������־����¼");
//��¼��־-------Ĭ����־��¼�����������ͷ���������������������ִ�й��̽������Ż����͵ò���ȷ�ĵ�����Ϣ
//so��������logp��������
myLogger.entering("Chapter11", "main");
//����־��¼�쳣
try {
Scanner sc=new Scanner(new FileInputStream("readme.txt"));
} catch (IOException e) {
myLogger.getLogger("com.mycompany.myapp").log(Level.WARNING,"Reading File failure",e);
}
System.out.println(myLogger.getResourceBundleName());
}
}