自定义封装Logger demo 小测试

  • 时间:
  • 浏览:0
  • 来源:大发5分快3_极速5分PK10

public void setReload(boolean flag) {

public void debug(String info) {

private Logger(String className) {

1》  log4j.properties 文件:

测试通过,但貌似可用,不过log4j源码貌似强大应用场景

public boolean isDebugEnabled() {

public void warn(String info) {

private Logger(Class c) {

private static void reload() {

public class test {

static Logger log = Logger.getLogger(test.class);

private Logger() {

public boolean isErrorEnabled() {

4:测试 

public boolean isTraceEnabled() {

public boolean isWarnEnabled() {

public static void main(String[] args) {

log4j.appender.file=org.apache.log4j.RollingFileAppender

     public void error(Object info, Throwable t){

public static Logger getLogger() {

public void trace(String info) {

public class Logger {

public void error(String info) {

public boolean isFatalEnabled() {

3》Logger文件

public static Logger getLogger(Class c) {

2》Log4jConfig:

public void info(String info) {

public static void main(String[] args) {

log4j.rootLogger=DEBUG,MINA,file

### 控制台 ###

System.out.println("log4j configfile path=" + path);

import org.apache.log4j.PropertyConfigurator;

public class Log4jConfig {

private static boolean isReload = true;

/**

log4j.appender.MINA=org.apache.log4j.ConsoleAppender

return new Logger(c);

System.out.println("***********************");

public boolean isInfoEnabled() {

public static Logger getLogger(String className) {

import org.apache.commons.logging.Log;