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