/** * Copyright (c) 2011-2012, James Zhan 詹波 (jfinal@126.com). * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.jfinal.log; /** * The five logging levels used by Log are (in order): * 1. DEBUG (the least serious) * 2. INFO * 3. WARN * 4. ERROR * 5. FATAL (the most serious) */ public abstract class Logger { private static final ILoggerFactory factory = createLoggerFactory(); public static Logger getLogger(Class<?> clazz) { return factory.getLogger(clazz); } public static Logger getLogger(String name) { return factory.getLogger(name); } private static ILoggerFactory createLoggerFactory() { try { Class.forName("org.apache.log4j.Logger"); Class<?> log4jLoggerFactoryClass = Class.forName("com.jfinal.log.Log4jLoggerFactory"); return (ILoggerFactory)log4jLoggerFactoryClass.newInstance(); // return new Log4jLoggerFactory(); } catch (Exception e) { return new JdkLoggerFactory(); } } public abstract void debug(String message); public abstract void debug(String message, Throwable t); public abstract void info(String message); public abstract void info(String message, Throwable t); public abstract void warn(String message); public abstract void warn(String message, Throwable t); public abstract void error(String message); public abstract void error(String message, Throwable t); public abstract void fatal(String message); public abstract void fatal(String message, Throwable t); public abstract boolean isDebugEnabled(); public abstract boolean isInfoEnabled(); public abstract boolean isWarnEnabled(); public abstract boolean isErrorEnabled(); public abstract boolean isFatalEnabled(); }