自定义封装Logger demo 小测试

  • 时间:
  • 浏览:4
  • 来源:大发彩神安卓下载—大发彩神官方下载

private Logger() {

3》Logger文件

public void info(String info) {

public void error(String info) {

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

public static Logger getLogger() {

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

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

public boolean isDebugEnabled() {

public void setReload(boolean flag) {

public static Logger getLogger(String className) {

public void warn(String info) {

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

     public void error(Object info, Throwable t){

1》  log4j.properties 文件:

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

public boolean isErrorEnabled() {

public class test {

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

return new Logger(c);

2》Log4jConfig:

public static void main(String[] args) {

public void trace(String info) {

private Logger(String className) {

public static Logger getLogger(Class c) {

public class Logger {

public boolean isInfoEnabled() {

public boolean isWarnEnabled() {

log4j.rootLogger=DEBUG,MINA,file

### 控制台 ###

private static void reload() {

import org.apache.commons.logging.Log;

private Logger(Class c) {

public static void main(String[] args) {

public boolean isTraceEnabled() {

public void debug(String info) {

import org.apache.log4j.PropertyConfigurator;

public class Log4jConfig {

private static boolean isReload = true;

/**

4:测试 

public boolean isFatalEnabled() {