1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.apache.log4j;
23
24
25 /***
26 Use this class to quickly configure the package.
27
28 <p>For file based configuration see {@link
29 PropertyConfigurator}. For XML based configuration see {@link
30 org.apache.log4j.xml.DOMConfigurator DOMConfigurator}.
31
32 @since 0.8.1
33 @author Ceki Gülcü */
34 public class BasicConfigurator {
35
36 protected BasicConfigurator() {
37 }
38
39 /***
40 Add a {@link ConsoleAppender} that uses {@link PatternLayout}
41 using the {@link PatternLayout#TTCC_CONVERSION_PATTERN} and
42 prints to <code>System.out</code> to the root category. */
43 static
44 public
45 void configure() {
46 Logger root = Logger.getRootLogger();
47 root.addAppender(new ConsoleAppender(
48 new PatternLayout(PatternLayout.TTCC_CONVERSION_PATTERN)));
49 }
50
51 /***
52 Add <code>appender</code> to the root category.
53 @param appender The appender to add to the root category.
54 */
55 static
56 public
57 void configure(Appender appender) {
58 Logger root = Logger.getRootLogger();
59 root.addAppender(appender);
60 }
61
62 /***
63 Reset the default hierarchy to its defaut. It is equivalent to
64 calling
65 <code>Category.getDefaultHierarchy().resetConfiguration()</code>.
66
67 See {@link Hierarchy#resetConfiguration()} for more details. */
68 public
69 static
70 void resetConfiguration() {
71 LogManager.resetConfiguration();
72 }
73 }