[Bug]: Log does not seem to write to stdout
Closed this issue · 1 comments
eugeneo commented
Describe the issue
I can not see infos/warnings, no matter what I set --minloglevel
to. Setting --stderrthreshold=0
works as expected.
Steps to reproduce the problem
Code:
int main(int argc, char** argv) {
absl::SetProgramUsageMessage("Echo server");
absl::ParseCommandLine(argc, argv);
absl::InitializeLog();
std::cout << "Hello, world!" << std::endl;
LOG(INFO) << "Info";
LOG(WARNING) << "Warning";
LOG(ERROR) << "Error";
return 0;
}
Bazel build:
cc_binary(
name = "echo_server",
srcs = [
"echo_server.cc",
],
deps = [
"@com_google_absl//absl/flags:parse",
"@com_google_absl//absl/log",
"@com_google_absl//absl/log:flags",
"@com_google_absl//absl/log:initialize",
],
)
Command line:
bazel run //src/tools:echo_server -- --minloglevel=0
What version of Abseil are you using?
abseil-cpp-20230802.0
What operating system and version are you using?
Ubuntu 22.04.3 LTS x86/64
What compiler and version are you using?
gcc version 11.4.0 (Ubuntu 11.4.0-1ubuntu1~22.04)
What build system are you using?
Bazel 6.3.2
Additional context
No response
derekmauro commented
I'm not sure what you think the expected behavior is here. Logging writes to stderr
(not stdout
) when --stderrthreshold
is set to the appropriate level, and you say that is working.
--minloglevel
controls whether the logging infrastructure runs at all for a particular logging level.
If you want logs to go somewhere besides stderr
, you need to use absl::AddLogSink()
.