2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 // Contibutors: "Luke Blanshard" <Luke@quiq.com>
19 // "Mark DONSZELMANN" <Mark.Donszelmann@cern.ch>
20 // "Muly Oved" <mulyoved@hotmail.com>
22 package org.apache.log4j;
26 Use this class to quickly configure the package.
28 <p>For file based configuration see {@link
29 PropertyConfigurator}. For XML based configuration see {@link
30 org.apache.log4j.xml.DOMConfigurator DOMConfigurator}.
33 @author Ceki Gülcü */
34 public class BasicConfigurator {
36 protected BasicConfigurator() {
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. */
46 Logger root = Logger.getRootLogger();
47 root.addAppender(new ConsoleAppender(
48 new PatternLayout(PatternLayout.TTCC_CONVERSION_PATTERN)));
52 Add <code>appender</code> to the root category.
53 @param appender The appender to add to the root category.
57 void configure(Appender appender) {
58 Logger root = Logger.getRootLogger();
59 root.addAppender(appender);
63 Reset the default hierarchy to its defaut. It is equivalent to
65 <code>Category.getDefaultHierarchy().resetConfiguration()</code>.
67 See {@link Hierarchy#resetConfiguration()} for more details. */
70 void resetConfiguration() {
71 LogManager.resetConfiguration();