zoukankan      html  css  js  c++  java
  • log4j的简介和使用

    一、log4j是什么

         引用官网的介绍 

         Log4j is a fast and flexible framework for logging application debugging messages.

          With log4j it is possible to enable logging at runtime without modifying the application binary. The log4j package is designed so that these statements can remain in shipped code without incurring a heavy performance cost. Logging behavior can be controlled by editing a configuration file, without touching the application binary.

         log4j是一个快速且灵活的打印日志的框架。

    二、log4j使用实例

         参考 http://www.codeceo.com/article/log4j-usage.html 

        注意:log4j的配置文件必须写在src/main/resource   或者  src/test/resource  中

    三、log4j的基本使用

        1、 Log4j由三个重要的组件构成:级别、存放器和布局(日志以什么level什么layout输出到哪个appender)

         level:日记记录的优先级priority,优先级由高到低分为 OFF ,FATAL ,ERROR ,WARN ,INFO ,DEBUG ,ALL。 Log4j建议只使用FATAL ,ERROR ,WARN ,INFO ,DEBUG这五个级别。

        layout:输出格式则控制了日志信息的显 示内容。

        appender:输出源,目的地是console还是file。

        Log4j支持两种配置文件格式,一种是XML格式的文件,一种是Java特性文件(键=值)。

      2、log4j的第一种配置方式    log4j.properties

          参考链接:http://www.codeceo.com/article/log4j-usage.html

      3、log4j的XML格式文件      log4j.xml

          参考链接:http://zengxiantao.iteye.com/blog/1881706

        

  • 相关阅读:
    【转】MyEclipse快捷键大全
    【转】MOCK测试
    【转】万亿移动支付产业的难点和痛点
    【转】【CTO俱乐部走进支付宝】探索支付宝背后的那些技术 部分
    CTO俱乐部
    tomcat修改默认端口
    VS2013试用期结束后如何激活
    项目中遇到的 linq datatable select
    LINQ系列:LINQ to DataSet的DataTable操作
    C#中毫米与像素的换算方法
  • 原文地址:https://www.cnblogs.com/pyxrk/p/6366364.html
Copyright © 2011-2022 走看看