Skip to content

Commit

Permalink
Make system temp directory ultimate fallback for logs.
Browse files Browse the repository at this point in the history
If we cannot write to user configuration directory, then write
the logs to the systems temp directory.

refs #7959
  • Loading branch information
stuartcampbell committed Sep 17, 2013
1 parent 5c0be44 commit 39c5e6e
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions Code/Mantid/Framework/Kernel/src/ConfigService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,14 @@ void ConfigServiceImpl::configureLogging()
m_logFilePath = getUserPropertiesDir() + "mantid.log";
logpath.assign(m_logFilePath);
logpath = logpath.absolute();
if (Poco::File(logpath).canWrite() == false)
{
// if we cannot write to the default directory then set use the system temp
logpath = Poco::Path::temp();
}

m_logFilePath = logpath.toString();

}
// Set the line in the configuration properties.
// this'll be picked up by LoggingConfigurator (somehow)
Expand All @@ -454,10 +461,10 @@ void ConfigServiceImpl::configureLogging()
// Configure the logging framework
Poco::Util::LoggingConfigurator configurator;
configurator.configure(m_pConf);
} catch (std::exception& e)
{
std::cerr << "Trouble configuring the logging framework " << e.what() << std::endl;
}
} catch (std::exception& e)
{
std::cerr << "Trouble configuring the logging framework " << e.what() << std::endl;
}

}

Expand Down

0 comments on commit 39c5e6e

Please sign in to comment.