JAVA log overview and log technology system

Advantage:

The information executed by the system can be selectively recorded to the specified location (console, file, database).

You can control whether to record logs at any time in the form of a switch without changing the source code.

The latest and best slf4j log implementation framework: Logback.

Logback is mainly divided into three technical modules:

Logback-core: The Logback-core module lays the foundation for the other two modules and is a must have.

Logback-classic: It is an improved version of log4j, and it fully implements slf4jAPI.

The Logbakc-access module integrates with Servlet containers such as Tomcat and Jetty to provide HTTP access logging functionality.

 public static final Logger LOGGER =LoggerFactory.getLogger("Test.class");
    public static void main(String[] args) {
        try {
            LOGGER.debug("main方法开始执行了~~");
            LOGGER.info("two");
            int a = 10;
            int b = 0;
            LOGGER.trace("a=" + a);
            LOGGER.trace("b=" + b);
            System.out.println(a / b);
        }catch(Exception e){
            e.printStackTrace();
            LOGGER.error("功能出现异常。"+e);
        }
    }

Guess you like

Origin blog.csdn.net/zhi6fui/article/details/123974281
log
log