log4cpp在unix下的使用
来源:互联网 发布:js confirm的返回值 编辑:程序博客网 时间:2024/05/16 02:20
引用自:http://blog.csdn.net/xiaolongzhou1225/article/details/1172338
今天终于完成了对log4cpp在unix下的使用,下面是一些总结
今天终于完成了对log4cpp在unix下的使用,下面是一些总结
1.将log4cpp-0.3.5rc3拷贝到unix下
2.进入log4cpp-0.3.5rc3目录,运行命令configure
3.使用make命令进行编译,会看到一些错误
首先是出错位置priority.hh
class LOG4CPP_EXPORT Priority {
public:
static const int MESSAGE_SIZE=8;
///// Some other declarations //////
};
解决方法
将代码改成
static const int MESSAGE_SIZE;
在priority.cpp里加一句
#include "PortabilityImpl.hh"
#include <log4cpp/Priority.hh>
#include <cstdlib>
const int log4cpp::Priority::MESSAGE_SIZE=8;
然后是"../include/log4cpp/FixedContextCategory.hh", line 171: Warning: log4cpp::FixedContextCategory::addA
ppender hides the virtual function log4cpp::Category::addAppender(log4cpp::Appender*).
"../include/log4cpp/FixedContextCategory.hh", line 171: Warning: log4cpp::FixedContextCategory::owns
Appender hides the virtual function log4cpp::Category::ownsAppender(log4cpp::Appender*, __rwstd::__r
b_tree<log4cpp::Appender*, std::pair<log4cpp::Appender*const, bool>, __rwstd::__select1st<std::pair<
log4cpp::Appender*const, bool>, log4cpp::Appender*>, std::less<log4cpp::Appender*>, std::allocator<s
td::pair<log4cpp::Appender*const, bool>>>::iterator&).
"FixedContextCategory.cpp", line 47: Error: Could not find a match for log4cpp::FixedContextCategory
::addAppender(log4cpp::Appender*).
需要修改FixedContextCategory.hh:
virtual void addAppender(Appender* appender) throw();
为 virtual void addAppender(Appender* appender) const throw();
FixedContextCategory.cpp:
virtual void addAppender(Appender* appender) throw();
为 virtual void addAppender(Appender* appender) const throw();
再次进行编译,就可以通过了,会在src目录生成liblog4cpp.la文件
4.测试
进入tests目录,使用make进行编译,会报"testbench.cpp", line 66: Error: The operation "log4cpp::CategoryStream << std::basic_string<char, s
td::char_traits<char>, std::allocator<char>>" is illegal.
"testbench.cpp", line 85: Error: The operation "log4cpp::CategoryStream << std::basic_string<char, s
td::char_traits<char>, std::allocator<char>>" is illegal.
将85行修改为: s<< log4cpp::CategoryStream::ENDLINE;
将66行修改为: log << log4cpp::Priority::ERROR;//log << str;
运行testmain cpp.log,在当前目录下会生成cpp.log的日志文件。
这只是log4cpp的初步使用,以后需要验证多线程情况下的使用,以及日志的备份,大小的设定等等
- log4cpp在unix下的使用
- log4cpp windows下运用(1)----log4cpp在windows下编译的修改
- Log4cpp的使用
- log4cpp库的使用
- log4cpp windows下运用(3)----log4cpp 使用需注意的点
- log4cpp的安装和使用
- log4cpp 学习过程(四) ---- log4cpp在VS2003上的编译
- log4cpp-【写日志】:使用log4cpp的基本步骤
- ubuntu下安装与使用Log4cpp
- ubuntu下安装与使用Log4cpp
- 使用LOG4CPP
- Log4cpp使用
- log4cpp - 使用
- log4cpp使用
- alias命令在linux/unix下的使用
- linux下编译log4cpp的方法
- Unix下onstat的使用
- log4cpp在项目中的封装使用(VC项目)
- C#只运行一个实例
- 循环语句if语句goto的综合应用
- log4cpp linux使用
- postgresql常用函数汇总
- CentOS设置服务开机自动启动
- log4cpp在unix下的使用
- 深入浅出 iOS 之生命周期
- Struts2+Spring 整合成功测试案例--整合过程中遇到的问题及解决方法(一)
- 状态模式
- UVA 5986 - Wizarding Duel
- Oracle APEX支持基于云计算的网络开发
- enable magento show error log
- 半平面交讲解 - N^2写法
- 两行代码,理解了一个小时! 两个数组记录邻接表! ( 刘汝佳白书)