c++ - 如何设置 log4cxx 控制台输出的颜色?

标签 c++ log4cxx

我可以找到 log4j 的解决方案,但不能找到 log4cxx 的解决方案。

最佳答案

我有一个简单的解决方案。

extern LoggerPtr logger;

#define LOG_TRACE(msg) LOG4CXX_TRACE(logger, msg)
#define LOG_DEBUG(msg) LOG4CXX_DEBUG(logger, msg)
#define LOG_INFO(msg) LOG4CXX_INFO(logger, msg)
#define LOG_INFO_H(msg) LOG4CXX_INFO(logger, "\33[0;42m" << msg << "\33[0m") // green
#define LOG_WARN(msg) LOG4CXX_WARN(logger, "\33[0;43m" << msg << "\33[0m") // yellow
#define LOG_ERROR(msg) LOG4CXX_ERROR(logger, "\33[0;41m" << msg << "\33[0m") // red
#define LOG_FATAL(msg) LOG4CXX_FATAL(logger, "\33[0;41m" << msg << "\33[0m") // red

关于c++ - 如何设置 log4cxx 控制台输出的颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14118703/

相关文章:

c++ - 将 JSON 对象作为 Boost 中的键值对插入现有 JSON 对象中

c++ - 无法在 C++ 中访问派生类的函数

C++ 线程名称映射和 log4cxx

visual-studio-2013 - 在 visual studio 2013 下构建 log4cxx

c++ - 在 visual studio 2012 中使用 Log4cxx

qt - 如何解决qmake项目中链接log4cxx时 undefined reference 错误

c++ - 为什么 C++ 模板数组长度推导需要类似于 "f(T (&a)[N]"?

c++ - 重新定义一个int错误

c++ - Visual C++ 静态初始值设定项异常行为

c++ - 使用 log4cxx 进行自定义和动态附加程序的配置