diff --git a/server/core/gateway.cc b/server/core/gateway.cc index 4164ffae8..2ee45dce4 100644 --- a/server/core/gateway.cc +++ b/server/core/gateway.cc @@ -753,10 +753,8 @@ static void print_log_n_stderr( { if (do_log) { - static bool log_is_inited = false; - if (log_is_inited || init_log()) + if (mxb_log_inited() || init_log()) { - log_is_inited = true; MXS_ERROR("%s%s%s%s", logstr, eno == 0 ? "" : " (", @@ -1860,6 +1858,14 @@ int main(int argc, char **argv) goto return_main; } + if (mxb_log_inited()) + { + // If the log was inited due to some error logging *and* we did not exit, + // we need to close it so that it can be opened again, this time with + // the final settings. + mxs_log_finish(); + } + if (!init_log()) { rc = MAXSCALE_BADCONFIG;