log4cpp在unix下的使用

来源:互联网 发布:js confirm的返回值 编辑:程序博客网 时间:2024/05/16 02:20
引用自:http://blog.csdn.net/xiaolongzhou1225/article/details/1172338
今天终于完成了对
log4cppunix下的使用,下面是一些总结
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的初步使用,以后需要验证多线程情况下的使用,以及日志的备份,大小的设定等等

原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 狙击精英3没子弹怎么办 干活干的手腕疼怎么办 干了活不给钱怎么办 干了活要不到钱怎么办 活干完了钱不给怎么办 微信语音聊天音量很小怎么办 一手软件崩溃钱卡住了怎么办 身上皮肤很黑怎么办?好想穿短裙 家里有很多小飞虫怎么办 家里有垃圾中飞出虫子怎么办 雷蛇笔记本很烫怎么办 登录监控器的账号锁了怎么办 悦借钱登录账号被锁怎么办 365账号登录被锁怎么办 台式电脑cpu温度过高怎么办 UG2.0打不开错误—15怎么办 键盘空格键删除键失灵怎么办 耳麦检测声音不分左右怎么办 吃生萝卜胃疼怎么办 幼兔拉稀怎么办没精神 自酿米酒酸了怎么办 用冰敷脸感觉红烫了怎么办 吃了海兔的内脏怎么办 吃了鱿鱼的吸盘怎么办 想开个烧烤店没学过怎么办 墨鱼汁弄衣服上怎么办 干鱿鱼泡开发黄怎么办 吃了芥末胃疼怎么办 手撕鱿鱼咸了怎么办 孕妇吃了点芥末怎么办 葡萄酒上面有一层白霉怎么办 手机一不小心把视频删了怎么办 柑橘7月份果实小怎么办 鹦鹉鱼身上有小白点怎么办 鹦鹉鱼身上烂了怎么办 红鹦鹉鱼变黑了怎么办 唱美声总夹嗓子怎么办 发财树树干出褶怎么办 月季花夏天换盆出现黄叶怎么办 刚种的月季枯了怎么办 新买的月季黄叶了怎么办