1 /* 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 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 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. 16 */ 17 18 // Contibutors: "Luke Blanshard" <Luke@quiq.com> 19 // "Mark DONSZELMANN" <Mark.Donszelmann@cern.ch> 20 // "Muly Oved" <mulyoved@hotmail.com> 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 }