001package org.apache.turbine.services.avaloncomponent; 002 003import org.apache.avalon.framework.logger.Logger; 004import org.apache.logging.log4j.LogManager; 005 006/* 007 * Licensed to the Apache Software Foundation (ASF) under one or more 008 * contributor license agreements. See the NOTICE file distributed with 009 * this work for additional information regarding copyright ownership. 010 * The ASF licenses this file to You under the Apache License, Version 2.0 011 * (the "License"); you may not use this file except in compliance with 012 * the License. You may obtain a copy of the License at 013 * 014 * http://www.apache.org/licenses/LICENSE-2.0 015 * 016 * Unless required by applicable law or agreed to in writing, software 017 * distributed under the License is distributed on an "AS IS" BASIS, 018 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 019 * See the License for the specific language governing permissions and 020 * limitations under the License. 021 */ 022 023/** 024 * A Log4J2 wrapper class for Logger. 025 * 026 * Use org.apache.fulcrum.yaafi.framework.logger.Log4j2Logger instead. 027 * 028 * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a> 029 */ 030@Deprecated 031public final class Log4j2Logger 032 implements Logger 033{ 034 // underlying implementation 035 private final org.apache.logging.log4j.Logger m_logger; 036 037 /** 038 * Create a logger that delegates to specified category. 039 * 040 * @param logImpl 041 * the category to delegate to 042 */ 043 public Log4j2Logger(final org.apache.logging.log4j.Logger logImpl) 044 { 045 m_logger = logImpl; 046 } 047 048 /** 049 * Log a debug message. 050 * 051 * @param message 052 * the message 053 */ 054 @Override 055 public void debug(final String message) 056 { 057 m_logger.debug(message); 058 } 059 060 /** 061 * Log a debug message. 062 * 063 * @param message 064 * the message 065 * @param throwable 066 * the throwable 067 */ 068 @Override 069 public void debug(final String message, final Throwable throwable) 070 { 071 m_logger.debug(message, throwable); 072 } 073 074 /** 075 * Determine if messages of priority "debug" will be logged. 076 * 077 * @return true if "debug" messages will be logged 078 */ 079 @Override 080 public boolean isDebugEnabled() 081 { 082 return m_logger.isDebugEnabled(); 083 } 084 085 /** 086 * Log a info message. 087 * 088 * @param message 089 * the message 090 */ 091 @Override 092 public void info(final String message) 093 { 094 m_logger.info(message); 095 } 096 097 /** 098 * Log a info message. 099 * 100 * @param message 101 * the message 102 * @param throwable 103 * the throwable 104 */ 105 @Override 106 public void info(final String message, final Throwable throwable) 107 { 108 m_logger.info(message, throwable); 109 } 110 111 /** 112 * Determine if messages of priority "info" will be logged. 113 * 114 * @return true if "info" messages will be logged 115 */ 116 @Override 117 public boolean isInfoEnabled() 118 { 119 return m_logger.isInfoEnabled(); 120 } 121 122 /** 123 * Log a warn message. 124 * 125 * @param message 126 * the message 127 */ 128 @Override 129 public void warn(final String message) 130 { 131 m_logger.warn(message); 132 } 133 134 /** 135 * Log a warn message. 136 * 137 * @param message 138 * the message 139 * @param throwable 140 * the throwable 141 */ 142 @Override 143 public void warn(final String message, final Throwable throwable) 144 { 145 m_logger.warn(message, throwable); 146 } 147 148 /** 149 * Determine if messages of priority "warn" will be logged. 150 * 151 * @return true if "warn" messages will be logged 152 */ 153 @Override 154 public boolean isWarnEnabled() 155 { 156 return m_logger.isWarnEnabled(); 157 } 158 159 /** 160 * Log a error message. 161 * 162 * @param message 163 * the message 164 */ 165 @Override 166 public void error(final String message) 167 { 168 m_logger.error(message); 169 } 170 171 /** 172 * Log a error message. 173 * 174 * @param message 175 * the message 176 * @param throwable 177 * the throwable 178 */ 179 @Override 180 public void error(final String message, final Throwable throwable) 181 { 182 m_logger.error(message, throwable); 183 } 184 185 /** 186 * Determine if messages of priority "error" will be logged. 187 * 188 * @return true if "error" messages will be logged 189 */ 190 @Override 191 public boolean isErrorEnabled() 192 { 193 return m_logger.isErrorEnabled(); 194 } 195 196 /** 197 * Log a fatalError message. 198 * 199 * @param message 200 * the message 201 */ 202 @Override 203 public void fatalError(final String message) 204 { 205 m_logger.fatal(message); 206 } 207 208 /** 209 * Log a fatalError message. 210 * 211 * @param message 212 * the message 213 * @param throwable 214 * the throwable 215 */ 216 @Override 217 public void fatalError(final String message, final Throwable throwable) 218 { 219 m_logger.fatal(message, throwable); 220 } 221 222 /** 223 * Determine if messages of priority "fatalError" will be logged. 224 * 225 * @return true if "fatalError" messages will be logged 226 */ 227 @Override 228 public boolean isFatalErrorEnabled() 229 { 230 return m_logger.isFatalEnabled(); 231 } 232 233 /** 234 * Create a new child logger. The name of the child logger is 235 * [current-loggers-name].[passed-in-name] Throws 236 * <code>IllegalArgumentException</code> if name has an empty element name 237 * 238 * @param name 239 * the subname of this logger 240 * @return the new logger 241 */ 242 @Override 243 public Logger getChildLogger(final String name) 244 { 245 return new Log4j2Logger(LogManager.getLogger(m_logger.getName() + "." + name)); 246 } 247}