Biblioteca Java - Blame information for rev 3
Subversion Repositories:
Rev | Author | Line No. | Line |
---|---|---|---|
3 | mihai | 1 | /* |
2 | * LoggFilter.java | ||
3 | */ | ||
4 | package lab.scd.logging; | ||
5 | |||
6 | import java.util.logging.*; | ||
7 | /** | ||
8 | * Class created by @author mihai | ||
9 | * | ||
10 | * This class is part of the laborator6_logging project. | ||
11 | * | ||
12 | * Handlerele filtreaza automat mesajele pe baza nivelului de logging setat. Programatorul | ||
13 | * are posibilitatea de a set un filtru custom in care sa se stabileasca anumite conditii | ||
14 | * pentru logg | ||
15 | */ | ||
16 | public class LoggFilter { | ||
17 | |||
18 | public static void main(String[] args){ | ||
19 | //construieste handler | ||
20 | ConsoleHandler handler = new ConsoleHandler(); | ||
21 | |||
22 | // Seteaza filtrul | ||
23 | handler.setFilter(new Filter() { | ||
24 | public boolean isLoggable(LogRecord record) { | ||
25 | if(record.getMessage().indexOf("test")!=-1) | ||
26 | return false; | ||
27 | return true; | ||
28 | } | ||
29 | }); | ||
30 | |||
31 | Logger logger = Logger.getLogger("lab.scd.logging"); | ||
32 | logger.setUseParentHandlers(false); | ||
33 | |||
34 | logger.addHandler(handler); | ||
35 | logger.info("Mesaj logat"); | ||
36 | logger.info("Mesaj de test"); | ||
37 | } | ||
38 | } |