Log:日志工具输出log的使用

  日志的简单使用,三种方式。

  1. org.apache.commons.logging.Log
    1
    2
    3
    4
    5
    //import org.apache.commons.logging.Log;
    //import org.apache.commons.logging.LogFactory;
    private static final Log log = LogFactory.getLog(xxxServiceImpl.class);

    log.info(Object msg);
  2. log4j 1.x 版本:org.apache.log4j.Logger
    1
    2
    3
    4
    //org.apache.log4j.Logger;
    private final Logger logger = Logger.getLogger(this.getClass());

    logger.info(Object msg);
  3. log4j 2.x 版本:org.apache.logging.log4j.Logger
    1
    2
    3
    private static final Logger logger = LogManager.getLogger(xxxClass.class);

    logger.info(String msg);
阅读更多

Java 日志工具使用

日志的简单使用,两种方式:org.apache.commons.logging.Log日志包,org.apache.log4j.Logger日志包。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
private static final Log log = LogFactory.getLog(this.getClass());

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static Logger logger = LoggerFactory.getLogger(xxxClass.class);

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
private static final Logger logger = LogManager.getLogger(xxxClass.class);

import java.util.logging.Logger;
Logger logger = Logger.getLogger("serviceLogger");