logging-log4cxx-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "log4cxx" <log4...@gallandfamily.com>
Subject Re: how to redirect log4cxx console messages
Date Mon, 24 Feb 2014 16:06:47 GMT
>Both the messages were displayed in console. But, i am designing my
>application which uses log4cxx, in such a way that it won't have any console
>window. In such a case where the messages logged ?

We faced the same issue and ended up redirecting stderr:

//First redirect stderr for initialization error handling
CString logInitErrorFile("myapp.log");
freopen(logInitErrorFile, "w", stderr);

Then, when we are done initializing, we set it back:
// And now back to the console once again for stderr
freopen("CON", "w", stderr);

Since you have no console, you could skip the second step I assume. This is windows specific
of course, but I'm sure 
you could do the same on whatever OSes you need.


View raw message