Logfile question

I’m trying to create a logfile that outputs only to the logfile and not to stdout console on my linux machine. But the logging data is going to the wrong place.

This is my code:

File logfile("application_gui.log");
FileLogger fl(logfile,T("Welcome to Application"),1000);

FileLogger::writeToLog(T("Testing 1 2 3...\n"));

Two problems:

  1. The “Welcome to Application” output goes to stdout when I only want it to go to the “application_gui.log”
  2. The “Testing 1 2 3…” output only goes to stdout and doesn’t even go to the “application_gui.log”

I tried setting the logger location with the following to go to the logfile:
FileLogger::setCurrentLogger(fl,false);

But I get this compile error:
ToolbarWorker.cpp:17: error: no matching function for call to ‘juce::Logger::setCurrentLogger(juce::FileLogger&, bool)’
juce_amalgamated.h:2516: note: candidates are: static void juce::Logger::setCurrentLogger(juce::Logger*, bool)

I can create a Logger object and setCurrentLogger works with it, but I don’t know how to specify the name of the text file with a Logger object, like this.

Logger* blah;
FileLogger::setCurrentLogger(blah,false);

Any help appreciated.

this is how i do is

if (shouldLogToFile)
	{
		/* already turned on */
		fileLogger = new FileLogger (ApplicationProperties::getInstance()->getUserSettings()->getFile().withFileExtension(T("log")), T("Debug log started"));
		Logger::setCurrentLogger (fileLogger);

		debugLogEnabled = true;
	}
	else
	{
		Logger::setCurrentLogger (NULL, true);
		fileLogger = 0;

		debugLogEnabled = false;
	}

Thanks atom but I’m getting a compile error on this line:

fileLogger = new FileLogger (ApplicationProperties::getInstance()->getUserSettings()->getFile().withFileExtension(T("log")), T("Debug log started"));
      FileLogger::setCurrentLogger (fileLogger);

Error:
error: expected constructor, destructor, or type conversion before ‘=’ token

Do you have the “fileLogger” instantiated somewhere else? If so can I see that?

So I figured out that I needed to do the logMessage() call.

And now logging for the “Testing 1 2 3!!!” text is going to the logfile. But everything is also going to stdout console.

How do I tell juce to only log to the logfile and nothing to stdout console?

Here is the working examnple:

File logfile("application_gui.log");
FileLogger fl(logfile,T("Welcome to Application"),1000);
if (logging is necessary) {
        fl.logMessage(T("Testing 1 2 3!!!!\n"));
}

Compile in release mode.