zoukankan      html  css  js  c++  java
  • log4cpp_note

    # log4cpp

    ## The first HelloWorld process of log4cpp

    1. The relationship between Category,Appender and Layout is as follow:

    > There are more than one Category in the system,and all of them are inherited from the same root,and each Category is responsible for recording its own log.Each Category can add mroe than one Appender.Each Appender specifies a destination for log,for example,a file,a character stream,or a windows log.when the Category records a log,the log is written to all the Appender attached to this Category.Each Appender includes a Layout,and this Layout define a format of the log on the Appender.

    2. Now revist the previous HelloWorld program,and we can see that the process is as follows:

    > 1. Create an Appender,and specify a Layout that is contains.
    > 2. Get the root of Category from system,and add the Appender to this Category.
    > 3. Setting the priority of the Category.
    > 4. Record log.
    > 5. close the Category.

    ## The Layout of log4cpp

    ###1. PatternLayout

    1. Three subclass of Layout:

    > * BasicLayout
    > * PatternLayout
    > * SimpleLayout

    2. PatternLayout

    > * %c category
    > * %d date
    > * %m message
    > * %p priority
    > * %n newline
    > * %r ms after the layout created
    > * %R seconds from 1970
    > * %u the number of clock cycles to date from the beginning of the process
    > * %x NDC

    3. An ideal format

    "%d: %p %c %x: %m%n"

  • 相关阅读:
    Docker 安装及使用
    明明白白学 同步、异步、阻塞与非阻塞
    ArrayList 并发操作 ConcurrentModificationException 异常
    shell 脚本防止ddos
    shell 脚本备份数据库
    shell 脚本猜数字
    shell 脚本检测主从状态
    tomcat 结合apache 动静分离
    shell 脚本检测网站存活
    zabbix 4.0 版本 yum安装
  • 原文地址:https://www.cnblogs.com/xintt/p/8837004.html
Copyright © 2011-2022 走看看