使用log4cxx在C++中记录特定的类
Using log4cxx for logging a particular class in C++
以下是我在项目中使用的示例log4cxx配置文件
# Set root logger level to INFO and its only appender to A1.
log4j.rootLogger=INFO, A1
# A1 is set to be a ConsoleAppender.
log4j.appender.A1=org.apache.log4j.ConsoleAppender
# A1 uses PatternLayout.
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%d{yy-MM-dd HH:mm:ss.SSS} %X{pname}:%X{pid} %-5p %l- %m%n
log4j.appender.A1.serverFileAppender=org.apache.log4j.RollingFileAppender
# Tweak the timestamp format so that it sorts easier
log4j.appender.A1.serverFileAppender.fileName=/tmp/client_cpp.log
当前,rootLogger
被设置为INFO
。有没有办法将其配置为只在某些.cpp文件中记录DEBUG
消息?例如,我有一个Consumer.cpp
文件,其中包含一些DEBUG
级别的日志消息。如何配置它,使其仅记录该文件中的DEBUG
消息?我在这里浏览了教程,但没有提交相关信息。
我通过在log4cxx.conf文件-中添加以下行解决了这个问题
log4j.category.ProducerImpl=DEBUG
相关文章:
- 将两个数组中的差异记录在第三个数组中
- 禁止在控制台上记录谷神星
- 创建 Spdlog 异步文件记录器时遇到困难
- fastrtps:如何在发布/订阅级别使用 DDS 历史记录?
- 如何将自定义记录器与websocketpp一起使用?
- C++结构到德尔福记录dll调用
- 如何判断SSL_read是否已经接收并处理了来自单个消息的所有记录
- 如何实现具有多个平台__FILE__和__LINE__信息的 C/C++ 可变参数日志记录宏?
- 我是否可以使用 win32 句柄以编程方式记录发送到/接收到 USB/COM 的内容
- 使用 Doxygen 记录枚举类值,而不启用EXTRACT_ALL
- 在C++中隐藏键盘记录器的控制台窗口
- 堆栈上的最大激活记录数
- 记录Doxygen中的命名
- 是否有可能以及如何使用log4cxx库每个进程创建独立的记录仪
- log4cxx:使用log4j.rootLogger以外的命名记录器
- 使用log4cxx在C++中记录特定的类
- 使用Log4cxx记录到windows事件
- Log4cxx日志记录语句挂起
- 使用log4cxx关闭日志记录以减少开销
- 使用 log4cxx 进行日志记录和过滤