【问题标题】:Using log4cxx for logging a particular class in C++使用 log4cxx 记录 C++ 中的特定类
【发布时间】:2015-04-25 14:21:43
【问题描述】:

以下是我在项目中使用的示例 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 消息?我浏览了here的教程,但没有归档相关信息。

【问题讨论】:

    标签: c++ logging log4cxx


    【解决方案1】:

    我通过在 log4cxx.conf 文件中添加以下行解决了这个问题 -

    log4j.category.ProducerImpl=DEBUG
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-06-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-15
      • 2021-10-14
      相关资源
      最近更新 更多