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 */
017package org.apache.log4j;
018
019
020import org.apache.log4j.spi.LoggerFactory;
021import org.apache.logging.log4j.spi.LoggerContext;
022
023/**
024 *
025 */
026public class Logger extends Category {
027
028    protected Logger(final String name) {
029        super(PrivateManager.getContext(), name);
030    }
031
032    Logger(final LoggerContext context, final String name) {
033        super(context, name);
034    }
035
036    public static Logger getLogger(final String name) {
037        return Category.getInstance(PrivateManager.getContext(), name);
038    }
039
040    public static Logger getLogger(final Class<?> clazz) {
041        return Category.getInstance(PrivateManager.getContext(), clazz);
042    }
043
044    public static Logger getRootLogger() {
045        return Category.getRoot(PrivateManager.getContext());
046    }
047
048    public static Logger getLogger(final String name, final LoggerFactory factory) {
049        return Category.getInstance(PrivateManager.getContext(), name, factory);
050    }
051
052    /**
053     * Internal Log Manager.
054     */
055    private static class PrivateManager extends org.apache.logging.log4j.LogManager {
056        private static final String FQCN = Logger.class.getName();
057
058        public static LoggerContext getContext() {
059            return getContext(FQCN, false);
060        }
061
062        public static org.apache.logging.log4j.Logger getLogger(final String name) {
063            return getLogger(FQCN, name);
064        }
065    }
066}