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    package org.apache.commons.transaction.util;
018    
019    import org.apache.log4j.Logger;
020    
021    /**
022     * Default logger implementation. Uses log4j logging.
023     *
024     * @version $Id: Log4jLogger.java 493628 2007-01-07 01:42:48Z joerg $
025     */
026    public class Log4jLogger implements LoggerFacade {
027        
028        protected Logger logger;
029        
030        public Log4jLogger(Logger logger) {
031            this.logger = logger;
032        }
033    
034        public Logger getLogger() {
035            return logger;
036        }
037    
038        public LoggerFacade createLogger(String name) {
039            return new Log4jLogger(Logger.getLogger(name));
040        }
041    
042        public void logInfo(String message) {
043            logger.info(message);
044        }
045    
046        public void logFine(String message) {
047            logger.debug(message);
048        }
049    
050        public boolean isFineEnabled() {
051            return logger.isDebugEnabled();
052        }
053    
054        public void logFiner(String message) {
055            logger.debug(message);
056        }
057    
058        public boolean isFinerEnabled() {
059            return logger.isDebugEnabled();
060        }
061    
062        public void logFinest(String message) {
063            logger.debug(message);
064        }
065    
066        public boolean isFinestEnabled() {
067            return logger.isDebugEnabled();
068        }
069    
070        public void logWarning(String message) {
071            logger.warn(message);
072        }
073    
074        public void logWarning(String message, Throwable t) {
075            logger.warn(message, t);
076        }
077        public void logSevere(String message) {
078            logger.error(message);
079        }
080    
081        public void logSevere(String message, Throwable t) {
082            logger.error(message, t);
083        }
084    }