• 测试最新的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;
    }

  • 相关阅读:
    asp.net mvc中ViewData、ViewBag和TempData的详解
    在asp.net WebForms中使用路由Route
    Sql Server批量删除指定表
    MongoDB安装并设置为windows服务以使其开机自启
    NPOI操作excel之写入数据到excel表
    NPOI操作excel之读取excel数据
    SQL Server 定时自动备份数据库
    如何用按钮的click事件去触发a标签的click事件
    C# Asp.net Quartz.NET作业调度之创建、安装、卸载、调试windows服务的简单事例
    c#中浅拷贝和深拷贝的理解
  • 原文地址:https://www.cnblogs.com/luhouxiang/p/3475939.html
Copyright © 2020-2023  润新知