测试最新的log4cplus1.1.2版

#include "stdafx.h"

#include <sstream>

class AB{
public:
    void do_test()
    {
        //LOG_DEBUG("abc");
        //LOG4CPLUS_DEBUG(_Logger(), __if_exists(this){'[' << this << ']' <<} L'[' <<  __FUNCTION__   << "] " << "abc" );

        do
        {
            if((_Logger()).isEnabledFor(log4cplus::DEBUG_LOG_LEVEL))
            {
                log4cplus::tostringstream _log4cplus_buf;//tostringstream
                _log4cplus_buf << __if_exists(this){'[' << this << ']' <<} L'[' <<   __FUNCTION__   << "] " << "abc";
                (_Logger()).forcedLog(log4cplus::DEBUG_LOG_LEVEL, _log4cplus_buf.str(), "e:\\work\\testlog4cplus\\main.cpp", 10);
            }
        } while (0);

    }

   // LOG_CLS_DEC();

    // LOG_CLS_DEC_EX( log4cplus_tool::GetModuleLoggerName() + LOG4CPLUS_TEXT('.') + LOG4CPLUS_C_STR_TO_TSTRING(__FUNCTION__) )

    static log4cplus::Logger & _Logger()
    {
        log4cplus::tstring s = log4cplus_tool::GetModuleLoggerName() + L'.' + log4cplus::helpers::towstring( __FUNCTION__  );
        size_t nPos = s.find(TCHAR(':'));
        s = s.substr(0, nPos);
        static log4cplus::Logger& s_logger = log4cplus::Logger::getInstance( s );
        return s_logger;
    };

};

void InitLog4cplusCfg()
{
    TCHAR szPath[MAX_PATH] = _T("");
    GetModuleFileName(NULL, szPath, MAX_PATH);
    ATLPath::Combine(szPath, szPath, _T("..\\log4cplus_test.cfg"));
    //LOG_INIT_EX(szPath);

    log4cplus::PropertyConfigurator::doConfigure(szPath);
}

int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow)
{   
    InitLog4cplusCfg();

    AB ab;
    ab.do_test();
    return 1;
}

转载于:https://www.cnblogs.com/luhouxiang/p/3475939.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值