• log4c demo


    #ifdef HAVE_CONFIG_H
    #include "config.h"
    #endif
    
    #include <stdio.h>
    
    #include "log4c.h"
    
    int main(int argc, char** argv){
        int rc = 0;
        log4c_category_t* mycat = NULL;
    
        if (log4c_init()){
            printf("log4c_init() failed");
            rc = 1;
        }else{
            mycat = log4c_category_get("log4c.examples.helloworld");
    
            log4c_category_log(mycat, LOG4C_PRIORITY_ERROR, "Hello World!");
    
            /* Explicitly call the log4c cleanup routine */
            if ( log4c_fini()){
                printf("log4c_fini() failed");
            }
        }
        return rc;
    }
    

      log4crc

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE log4c SYSTEM "">
    
    <log4c version="1.2.4">
    
            <config>
                    <bufsize>0</bufsize>
                    <debug level="2"/>
                    <nocleanup>0</nocleanup>
                    <reread>1</reread>
            </config>
    
            <category name="root" priority="notice"/>
            <category name="six13log.log" priority="error" appender="stdout" />
    
            <rollingpolicy name="myrollingpolicy" type="sizewin" maxsize="1024" maxnum="10" />
    
            <appender name="myrollingfileappender" type="rollingfile" logdir="." prefix="myprefix" layout="dated" rollingpolicy="myrollingpolicy" />
    
            <appender name="stdout" type="stream" layout="basic"/>
            <appender name="stderr" type="stream" layout="dated"/>
            <appender name="syslog" type="syslog" layout="basic"/>
    
            <appender name="s13file" type="s13_file" layout="basic"/>
            <appender name="plain_stderr" type="s13_stderr" layout="none"/>
            <appender name="cat_stderr" type="s13_stderr" layout="catlayout"/>
            <appender name="xml_stderr" type="s13_stderr" layout="xmllayout"/>
            <appender name="user_stderr" type="s13_stderr" layout="userlayout"/>
    
            <layout name="basic" type="basic"/>
            <layout name="dated" type="dated"/>
    
            <layout name="catlayout" type="s13_cat"/>
            <layout name="xmllayout" type="s13_xml"/>
            <layout name="none" type="s13_none"/>
            <layout name="userlayout" type="s13_userloc"/>
    
            <category name="six13log.log.app.application2" priority="debug" appender="cat_stderr" />
            <category name="six13log.log.app.application3" priority="debug" appender="user_stderr" />
            <category name="six13log.log.app" priority="debug" appender="myrollingfileappender" />
            <category name="log4c.examples.helloworld" priority="debug" appender="aaa"/>
    </log4c>
    

      编译命令

    gcc log4c.c -o log4c -llog4c
    

      

  • 相关阅读:
    MQ
    redis
    MongoDB
    进程相关命令
    catalina.sh
    tomcat-jvm
    中间件简介
    websphere
    mysql
    shell变量与字符串操作
  • 原文地址:https://www.cnblogs.com/luckygxf/p/12260094.html
Copyright © 2020-2023  润新知