如何在C中为任何程序创建日志文件 [英] How to create a log file for any program in C

查看:94
本文介绍了如何在C中为任何程序创建日志文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我是C语言的新手.我已经用C语言编写了一个代码,想为所有错误和不支持的功能生成一个日志文件.如何为程序创建日志文件?

我的程序结构如下:

Hello,

I am a new to C. I had written a code in C and want to generate a log file for all errors and unsupported functionality. How can I create a log file for a program?

My program structure is like:

main()
{ 
  int i = abc();
  if (i != 0)
    //put error in log file

  int j = PQR();
  if ( j != 0)
    //put error in log file
}
abc()
{
 int k = xyz();
 if ( k != 0)
    //put error in log file
}
PQR()
{
 //some code
}
xyz()
{
 //some code
}


请帮帮我.
在此先感谢您.


Please help me out.
Thanks in advance.

推荐答案

Log4C 是我发现的大多数人所使用的.

看一下这些登录C的方法:
Log4c:记录C库 [ ^ ]
使用Pantheios C API向C程序添加日志记录 [ http://stackoverflow.com/questions/613919/c-logging-apis [ ^ ]
Log4C is what i found most of the people using.

Have a look at these ways of logging in C:
Log4c : Logging for C Library[^]
Adding Logging to C Programs with the Pantheios C API[^]
http://stackoverflow.com/questions/613919/c-logging-apis[^]


谢谢这么多的答复. :-O
Thak you so much for the reply. :-O


这篇关于如何在C中为任何程序创建日志文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆