-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogging.java
More file actions
47 lines (41 loc) · 1.55 KB
/
Logging.java
File metadata and controls
47 lines (41 loc) · 1.55 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
42
43
44
45
46
47
package Chapter11Throwable;
import java.io.IOException;
import java.util.logging.ConsoleHandler;
import java.util.logging.FileHandler;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.Logger;
public class Logging {
//������־��¼��
Logger logger=Logger.getLogger("Chapter11/Logging");
public Logging(){
System.out.println(this.getClass().getClassLoader().getResource("").getPath());
logger.info("��¼�����FINE�����ϴ���");
//�ƹ������ļ�������Ĭ����־��¼����
logger.setLevel(Level.FINE);
//�ƹ������ļ�-----���ô���������????????????????????????????????û�иijɹ�
Handler handler=new ConsoleHandler();
handler.setLevel(Level.FINE);
//��ϣ���ڿ���̨�����־��Ϣ
logger.setUseParentHandlers(false);
logger.addHandler(handler);
//��װ�Լ��Ĵ�����
try {
FileHandler fileHandler=new FileHandler();
System.out.println(fileHandler.getFormatter());
logger.addHandler(fileHandler);
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
LogManager logManager=LogManager.getLogManager();
System.out.println(logManager.getProperty("java.util.logging.ConsoleHandler.level"));
}
public static void main(String[] args) {
new Logging();
}
}