0

Good afternoon guys,

I'm working on a project that is using a Qt library in Visual Studio 2008. In this project I am using log4cxx 0.10.0 which is working fine. However, I am unable to get it to display in (this projects) console. I believe the reason has to do with it being a win32 application.

Anyone familiar with log4j(cxx) knows there is a properties file to configure.

Within that file, I have it writing to the console, but nothing is displayed. The .cmd won't pop up like other programs I have written, and it will not display in the VS console like qDebug().

Any ideas on how to go about fixing this?

fisherml
  • 65
  • 1
  • 5
  • 16

1 Answers1

0

QDebug is probably writing to the stderr, while printf or your log functions are connected only to stdout.

Show the console in Visual Studio

You have two different ways to show the black console/terminal window from Visual Studio:

One: Visual C++ Enable Console

Add the following somewhere in your program before you start printing out to the console:

#include <stdio.h>

// ...

AllocConsole();
freopen("conin$","r",stdin);
freopen("conout$","w",stdout);
freopen("conout$","w",stderr);
// printf("Debugging Window:\n");

Or you can tell Visual Studio that you are writing a console program and to make one for you.

Show console window when debugging Win32 MFC application in VS2010

Project > Properties > Configuration Properties > Linker > System > SubSystem

(This is the navigation to find the setting in VS 2010, it may be a little different for VS 2008)

Change from Windows (/SUBSYSTEM:WINDOWS) to Console (/SUBSYSTEM:CONSOLE).

Redirect stderr or stdout

Or a third option that you could try is to get your logging to print to the stderr, just like QDebug.

http://cboard.cprogramming.com/c-programming/26852-stderr-vs-stdout.html

FILE *myerr = freopen("error.log", "wb", stderr);

Hope that helps.

Community
  • 1
  • 1
phyatt
  • 18,472
  • 5
  • 61
  • 80