A example of Log4c
来源:互联网 发布:杭州淘宝代运营hzjttp 编辑:程序博客网 时间:2024/05/02 01:17
#include <stdio.h>
#include "log4c.h"
int main(int argc,char **argv){
int rc;
log4c_category_t *mycat=NULL:
if(log4c_init()){ // 1 step
printf("log4c_init() failed/n");
rc=1;
}
else{
mycat=log4c_category_get("log4c.helloworld"); //2 step
log4c_category_log(mycat,LOG4C_PRIORITY_TRACE,"Hello world/n"); //3 step
if(log4c_fini()){ //4 step
printf("log4c_fini() failed/n");
}
}
}
The most important of run this program is setting configuration file ---log4crc.
Exp:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE log4c SYSTEM "">
<log4c version="1.2.1">
<config>
<bufsize>0</bufsize>
<debug level="2"/>
<nocleanup>0</nocleanup>
<reread>1</reread>
</config>
<rollingpolicy name="myrollingpolicy" type="sizewin" maxsize="1024" maxnum="10" />
<category name="log4c.helloworld" priority="trace" appender="startrun"/>
<appender name="startrun" type="rollingfile" logdir="." prefix="logfile" layout="none" rollingpolicy="myrollingpolicy" />
<appender name="stdout" type="stream" layout="basic"/>
<appender name="stderr" type="stream" layout="dated"/>
<appender name="run.log" type="stream" layout="none"/>
<appender name="syslog" type="syslog" layout="basic"/>
<layout name="basic" type="basic"/>
<layout name="dated" type="dated"/>
<layout name="catlayout" type="you can set the cat format"/>
<layout name="xmllayout" type="you can set the xml format"/>
<layout name="none" type="none"/>
<layout name="userlayout" type="you can set other types output format "/>
</log4c>
#include "log4c.h"
int main(int argc,char **argv){
int rc;
log4c_category_t *mycat=NULL:
if(log4c_init()){ // 1 step
printf("log4c_init() failed/n");
rc=1;
}
else{
mycat=log4c_category_get("log4c.helloworld"); //2 step
log4c_category_log(mycat,LOG4C_PRIORITY_TRACE,"Hello world/n"); //3 step
if(log4c_fini()){ //4 step
printf("log4c_fini() failed/n");
}
}
}
The most important of run this program is setting configuration file ---log4crc.
Exp:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE log4c SYSTEM "">
<log4c version="1.2.1">
<config>
<bufsize>0</bufsize>
<debug level="2"/>
<nocleanup>0</nocleanup>
<reread>1</reread>
</config>
<rollingpolicy name="myrollingpolicy" type="sizewin" maxsize="1024" maxnum="10" />
<category name="log4c.helloworld" priority="trace" appender="startrun"/>
<appender name="startrun" type="rollingfile" logdir="." prefix="logfile" layout="none" rollingpolicy="myrollingpolicy" />
<appender name="stdout" type="stream" layout="basic"/>
<appender name="stderr" type="stream" layout="dated"/>
<appender name="run.log" type="stream" layout="none"/>
<appender name="syslog" type="syslog" layout="basic"/>
<layout name="basic" type="basic"/>
<layout name="dated" type="dated"/>
<layout name="catlayout" type="you can set the cat format"/>
<layout name="xmllayout" type="you can set the xml format"/>
<layout name="none" type="none"/>
<layout name="userlayout" type="you can set other types output format "/>
</log4c>
- A example of Log4c
- A example of pointer
- A wrong example of pointer
- A good example of equals()
- SQL: A example of creating a procedure
- a simple example of Ado.net
- A example of "Connect to ArcIMS"
- A example of "Connect to ArcSDE"
- Sun DefaultColorPhone : A programming example of TouchScreen.
- A example of NF_IP_PRE_ROUTING module(转载)
- A example of NF_IP_PRE_ROUTING module(转载)
- A Simple Example of Weak Ref Cursor
- A Example of Factory Method for Java
- Example of a SysTray App in Win32
- A example of NF_IP_PRE_ROUTING module(转载)
- A simple example of PHP closure
- Log4C++
- Example of a package of the server on Golang
- 开篇
- smart client
- PDA项目的开发
- NP完全性问题
- 使用正则表达式操作html标签中的特定属性
- A example of Log4c
- 如何使用cdonts组件发送html格式邮件
- ZOJ 2411 Link Link Look
- 想读点书
- 技术网站
- hal.dll损坏时,你该怎么办?
- IE中实现图片的拖拽
- C++网络开发包ACE环境的配置与调试
- 管道的故事