Logging output



You had said in another post that if I compile my juce application in release mode, the logfile output will only go to the logfile and won’t also go the stdout console.

Well I tested with the juce demo application, compiled it in Release mode, but the output in juce demo still goes to the logfile as well as stdout. I would really like to know how to configure logging to only go to the logfile and nothing goes to stdout console. Any thoughts?

To test this assertion, I edited /juce/extras/juce demo/src/ApplicationStartup.cpp as follows:

        // this little function just demonstrates a few system info calls
        Logger::outputDebugString (collectSomeSystemInfo());

        File logfile("application_gui.log");
        FileLogger fl(logfile,T("Application juce GUI interface starting"),1000);

And compiled in Release mode:
make CONFIG=Release

My output to stdout running jucedemo shows the logfile output when it shouldn’t be going to stdout:

root@thor:/usr/src/juce/extras/juce demo/build/linux/build# ./jucedemo
Time and date: 12 Feb 2010 2:12:40 pm
Operating system: Linux
CPU vendor: GenuineIntel
CPU speed: 1401MHz

Number of CPUs: 2
CPU has MMX: yes
CPU has SSE: yes
CPU has SSE2: yes
CPU has 3DNOW: no
Memory size: 2004MB
Found network card MAC address: 00-1f-e1-1b-29-9a
Found network card MAC address: 00-00-00-00-00-00
Current executable file: /usr/src/juce/extras/juce demo/build/linux/build/jucedemo
Current application file: /usr/src/juce/extras/juce demo/build/linux/build/jucedemo
User home directory: /root
User documents directory: /root
User application data directory: /root
Common application data directory: /var
Temp directory: /var/tmp

Application juce GUI interface starting
Log started: 12 Feb 2010 2:12:40 pm

^Croot@thor:/usr/src/juce/extras/juce demo/build/linux/build#


Thanks, you’re right, it does indeed always print the message. Might have been easier to just look inside FileLogger::logMessage and see what it does rather than writing a program to prove it, though!

I suppose that in a console app you might want to avoid the messages in a release version, so I should probably change it to use a DBG macro in there.


I am still learning. The way I thought to help me understand the issue was to use the jucedemo sample application because I knew that your Makefile was correct for building a Release version of the program. Therefore, I could easily test the behavior of your application for stdout console logging, thus eliminating confounding variables, which would help me troubleshoot my own application. Because I thought the problem was with my own Makefile.

Thanks for your input. I will do my best next time to look inside of the members to see and learn.


Yes that would be very useful, thanks. But in the meantime I’m going to take it as a challenge to modify my own FileLogger::logMessage to log only to logfile and not stdout console.


[quote]But in the meantime I’m going to take it as a challenge to modify my own FileLogger::logMessage to log only to logfile and not stdout console.

Well, have fun doing that, but I actually checked in an updated version yesterday if you need it!


Thank you!

Check out the new code and the new Jucedemo is quite impressive looking with the graphics rendering demo. Will definitely be checking this out some more.

Also, the new code obviously works and compile in release mode will only log to the logfile (and not stdout console) with FileLogger::logMessage.

I also noticed in FileLogger::logMessage that you changed the line from:

Logger::outputDebugString (message);


DBG (message);

I didn’t know that outputDebugString would output to stdout console in release mode. I have a lot to learn. Thanks again.