diff --git a/spectrum/src/main.cpp b/spectrum/src/main.cpp index c56aef336818fa5551e91a53fbec4c01e5ce71ed..7efe1e98a1ec2b40daf30602a482d924e7ab95ca 100644 --- a/spectrum/src/main.cpp +++ b/spectrum/src/main.cpp @@ -315,7 +315,6 @@ int main(int argc, char **argv) } #endif - Logging::initMainLogging(&config); #ifndef WIN32 if (!CONFIG_STRING(&config, "service.group").empty() ||!CONFIG_STRING(&config, "service.user").empty() ) { @@ -373,11 +372,15 @@ int main(int argc, char **argv) return -2; } } - else if (!storageBackend->connect()) { + else if (!storageBackend->connect()) { std::cerr << "Can't connect to database. Check the log to find out the reason.\n"; return -1; } + // Logging has to be initialized after all std:cerr output here, because + // it forwards std::cerr to log file. + Logging::initMainLogging(&config); + UserManager userManager(&transport, &userRegistry, storageBackend); userManager_ = &userManager;