001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 018// Contibutors: "Luke Blanshard" <Luke@quiq.com> 019// "Mark DONSZELMANN" <Mark.Donszelmann@cern.ch> 020// "Muly Oved" <mulyoved@hotmail.com> 021 022package org.apache.log4j; 023 024 025/** 026 Use this class to quickly configure the package. 027 028 <p>For file based configuration see {@link 029 PropertyConfigurator}. For XML based configuration see {@link 030 org.apache.log4j.xml.DOMConfigurator DOMConfigurator}. 031 032 @since 0.8.1 033 @author Ceki Gülcü */ 034public class BasicConfigurator { 035 036 protected BasicConfigurator() { 037 } 038 039 /** 040 Add a {@link ConsoleAppender} that uses {@link PatternLayout} 041 using the {@link PatternLayout#TTCC_CONVERSION_PATTERN} and 042 prints to <code>System.out</code> to the root category. */ 043 static 044 public 045 void configure() { 046 Logger root = Logger.getRootLogger(); 047 root.addAppender(new ConsoleAppender( 048 new PatternLayout(PatternLayout.TTCC_CONVERSION_PATTERN))); 049 } 050 051 /** 052 Add <code>appender</code> to the root category. 053 @param appender The appender to add to the root category. 054 */ 055 static 056 public 057 void configure(Appender appender) { 058 Logger root = Logger.getRootLogger(); 059 root.addAppender(appender); 060 } 061 062 /** 063 Reset the default hierarchy to its defaut. It is equivalent to 064 calling 065 <code>Category.getDefaultHierarchy().resetConfiguration()</code>. 066 067 See {@link Hierarchy#resetConfiguration()} for more details. */ 068 public 069 static 070 void resetConfiguration() { 071 LogManager.resetConfiguration(); 072 } 073}