Anton K Anton K - 4 months ago 72
C++ Question

Getting rid of atlTraceGeneral category shown in ATLTRACE output

After upgrading to VS2013 I started receiving all my ATLTRACE2 messages in a "() : atlTraceGeneral - My output" format.


ATLTRACE(_T("This is my data: %d\n"), 124);

... shown as

dllmain.cpp(1121) : atlTraceGeneral - This is my data: 124

I don't need any additional info. Is here some way to get back to the previous format so that the output would be just

This is my data: 124


The only working fix is to undef ATLTRACE under _DEBUG macro and implement trace by yourself. Guys at Microsoft recommended the same.

The solution looks like this:

#ifdef _DEBUG
#ifdef ATLTRACE 
#undef ATLTRACE2

#define ATLTRACE CustomTrace
#endif // ATLTRACE
#endif // _DEBUG

with the following CustomTraces:

void CustomTrace(const wchar_t* format, ...)
    const int TraceBufferSize = 1024;
    wchar_t buffer[TraceBufferSize];

    va_list argptr; va_start(argptr, format);
    vswprintf_s(buffer, format, argptr);


void CustomTrace(int dwCategory, int line, const wchar_t* format, ...)
    va_list argptr; va_start(argptr, format);
    HookTrace(format, argptr);