VC学习笔记----log4cxx

Objects

  • Logger(Category):logger对象,真正完成日志记录功能
  • Layout(format):控制输出日志消息的显示样式。
  • Appender(output device):用来输出日志到某些设备上,比如文件、syslog、socket等。

Configuration

  • Name
  • Level: TRACE < DEBUG < INFO < WARN < ERROR < FATAL

Librarian->General->Output File=LibD\apr-1.lib
Librarian->General->Output File=LibR\aprutil-1.lib
Librarian->General->Output File=.\LibD\xml.lib
Librarian->General->Output File=.\LibR\xml.lib

Installation

apr-util\include\apu.hw

#define APU_HAVE_APR_ICONV 1
改为
#define APU_HAVE_APR_ICONV 0

commands

cd apache-log4cxx-**
configure.bat
configure-aprutil.bat

Open solution

  • apache-log4cxx-0.10.0\projects\log4cxx.dsw
  • log4cxx 设置为启动项.
  • Build Solution

D:\log4cxx-src\apache-log4cxx-0.10.0\src\main\include\log4cxx/spi/loggingevent.h(155): error C2252: 只能在命名空间范围内显式实例化模板' 错误.
a) 双击 "输出" 窗口中的错误行, 此时会在 "代码窗口" 中出现错误的位置.
b) 选择 LOG4CXX_LIST_DEF, 按键盘 F12, 此时会跳转到该宏的定义

#define LOG4CXX_LIST_DEF(N, T) \
template class LOG4CXX_EXPORT std::allocator<T>; \
template class LOG4CXX_EXPORT std::vector<T>; \
typedef std::vector<T> N
替换为:
#define LOG4CXX_LIST_DEF(N, T) \
typedef std::vector<T> N

network_io\unix\multicast.c(137): error C2079: “mip”使用未定义的 struct“group_source_req"' 等错误.
双击第一行出错输出, 将 136 和 148 行的 #if MCAST_JOIN_SOURCE_GROUP 注释, 替换为 #if defined (group_source_req)

..\src\main\cpp\stringhelper.cpp(64): error C2039: “insert_iterator”: 不是“std”的成员' 等错误.
在该 .cpp 中(stringhelper.cpp) 加入头文件 :

'无法解析的外部符号 xxx' 等错误.
将 apr, aprutil, xml 添加至 log4cxx project 的引用中.

  • Rebuild solution: 否则可能会造成 '无法打开 apr_iconv.h' 错误. 个人怀疑是第 5 步中, configure-aprutil.bat 脚本中的 sed 命令没有正确更新文件的时间所致

reference:

http://logging.apache.org/log4cxx/usage.html
http://cn.waterlin.org/cpp/log4cxx.html
http://blog.csdn.net/rabbit729/article/details/2772179
http://blog.csdn.net/kungbx/article/details/6129564
http://hi.baidu.com/gaocher/blog/item/8f17e92729a56c7635a80ff2.html
http://blog.csdn.net/everettjf/article/details/6194933
http://hi.baidu.com/antbean1988/blog/item/40b2531cf8d271d3c3fd7898.html
http://hi.baidu.com/antbean1988/blog/item/40b2531cf8d271d3c3fd7898.html

posted @ 2020-07-16 10:05  Lee.Yan  阅读(269)  评论(0编辑  收藏  举报