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);
阅读更多