In addition, Wt also logs to std::cerr when successfully opening a file (src/Wt/WLogger.C):
if (ofs->is_open()) {
std::cerr
<< "INFO: Opened log file (" << path.c_str() << ")."
<< std::endl;
o_ = ofs;
ownStream_ = true;
} else {
delete ofs;
std::cerr
<< "ERROR: Could not open log file (" << path.c_str() << ")."
<< "We will be logging to std::cerr again."
<< std::endl;
o_ = &std::cerr;
ownStream_ = false;
}
}
Ideally, it would be nice not to write anything at all on success - not even to std::out. Perhaps this makes more sense if you take into account my particular use case. I am trying to use the log management system in AWS, which captures all writes to the console; thus, I'd rather not have any text coming up which is not directly produced by the application logging so that in the future I can push those messages as events into some kind of searchable log. As things stand, I get:
2019-09-20 11:49:09.065640 [INFO] [backend.web] Started web v0.0.1
2019-09-20 11:49:09.065769 [INFO] [backend.web] Starting wthttp server.
INFO: Opened log file (/dev/null).
INFO: Opened log file (/dev/null).
2019-09-20 11:49:11.654205 [INFO] [backend.web.application] [OV3zJ3ocP2RGPCmg] ::Creating application
2019-09-20 11:49:11.654444 [INFO] [backend.web.application] [OV3zJ3ocP2RGPCmg] ::Finished creating application
2019-09-20 11:49:12.605736 [INFO] [backend.web.application] [UISwxg5es7PPtVBM] ::Creating application
2019-09-20 11:49:12.606238 [INFO] [backend.web.application] [UISwxg5es7PPtVBM] ::Finished creating application
2019-09-20 11:49:16.128893 [INFO] [backend.web] Finished wthttp server.
I'd love to be able to get rid of those "Opened log file" lines.
Many thanks for your time.