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.legacy.core; 018 019import org.apache.logging.log4j.Level; 020import org.apache.logging.log4j.Logger; 021import org.apache.logging.log4j.spi.LoggerContext; 022 023/** 024 * Provide access to Log4j Core Logger methods. 025 */ 026public final class CategoryUtil { 027 028 private CategoryUtil() { 029 } 030 031 public static boolean isAdditive(Logger logger) { 032 if (logger instanceof org.apache.logging.log4j.core.Logger) { 033 return ((org.apache.logging.log4j.core.Logger) logger).isAdditive(); 034 } 035 return false; 036 } 037 038 public static void setAdditivity(Logger logger, boolean additivity) { 039 if (logger instanceof org.apache.logging.log4j.core.Logger) { 040 ((org.apache.logging.log4j.core.Logger) logger).setAdditive(additivity); 041 } 042 } 043 044 public static Logger getParent(Logger logger) { 045 if (logger instanceof org.apache.logging.log4j.core.Logger) { 046 return ((org.apache.logging.log4j.core.Logger) logger).getParent(); 047 048 } 049 return null; 050 } 051 052 public static LoggerContext getLoggerContext(Logger logger) { 053 if (logger instanceof org.apache.logging.log4j.core.Logger) { 054 return ((org.apache.logging.log4j.core.Logger) logger).getContext(); 055 } 056 return null; 057 } 058 059 public static void setLevel(Logger logger, Level level) { 060 if (logger instanceof org.apache.logging.log4j.core.Logger) { 061 ((org.apache.logging.log4j.core.Logger) logger).setLevel(level); 062 063 } 064 } 065}