Biblioteca Java - Blame information for rev 3
Subversion Repositories:
Rev | Author | Line No. | Line |
---|---|---|---|
3 | mihai | 1 | package lab.scd.logging; |
2 | import java.util.logging.Level; | ||
3 | import java.util.logging.Logger; | ||
4 | |||
5 | /* | ||
6 | * TestLogging.java | ||
7 | */ | ||
8 | |||
9 | /** | ||
10 | * Class created by @author mihai | ||
11 | * | ||
12 | * This class is part of the laborator6_logging project. | ||
13 | * | ||
14 | * Clasa exemplifica folosire mecanismului de logging inclus in sdk 1.5.0 | ||
15 | */ | ||
16 | public class TestLogging { | ||
17 | public static void main(String[] args) { | ||
18 | // Get a logger; the logger is automatically created if | ||
19 | // it doesn't already exist | ||
20 | /** | ||
21 | * Primul pas este de obtinere a unui obiect de tip Logger.Daca acesta | ||
22 | * nu exista va fi construit automat si returnat de betoda getLogger() | ||
23 | */ | ||
24 | Logger logger = Logger.getLogger("lab.scd.logging"); | ||
25 | |||
26 | |||
27 | /** | ||
28 | * Mesajele pot fi logate selectand diferite nivele de severitate | ||
29 | */ | ||
30 | logger.severe("my severe message"); | ||
31 | logger.warning("my warning message"); | ||
32 | logger.info("my info message"); | ||
33 | logger.config("my config message"); | ||
34 | logger.fine("my fine message"); | ||
35 | logger.finer("my finer message"); | ||
36 | logger.finest("my finest message"); | ||
37 | |||
38 | /** | ||
39 | * Este de asemenea posibila logarea exceptiilor | ||
40 | */ | ||
41 | |||
42 | //construieste un obiect de tip exceptie pentru teste | ||
43 | Exception ex = new IllegalStateException(); | ||
44 | logger.log(Level.SEVERE, "Uncaught exception", ex); | ||
45 | } | ||
46 | } |