Log messages always additionally print to console, even in release builds
name: Log messages always additionally print to console, even in release builds
Describe the bug
Lines 40-44 of omapip/errwarn.c define
log_perror differently based on whether or not it is a DEBUG build. This is done in order to print all log messages to stderr in addition to logging them to syslog if compiled with
However, the definitions are currently as follows:
#ifdef DEBUG int log_perror = -1; #else int log_perror = 1; #endif
log_perror is always nonzero no matter whether
DEBUG is defined or not, thus always causing all log_*() functions to print log messages to stderr in addition to logging them to syslog.
For our application, we are redirecting output from stderr to syslog, and we have a very noisy log because we are seeing all log messages at INFO level and above twice as well as all DEBUG-level messages show up in our syslogs, even though DEBUG-level messages are disabled in release builds.
Please let me know if you have any questions.
- Compile dhcp in non-DEBUG mode (i.e., don't define
- Run a DHCP program (e.g., dhcrelay) in non-daemon mode (or run in daemon mode but make sure to have a facility to redirect stderr to somewhere visible, like syslog)
- Notice that all log_*() functions are also echoed to stderr, although they should not be
If compiled without defining
DEBUG, log messages should not also get output to stderr
- ISC DHCP version: All releases (it appears this bug has existed since 1/26/2000)
- OS: All
I originally submitted this bug via your old bug reporting system as "ISC-Bugs #47288" on 3/8/2018. It appears that system was deprecated soon thereafter?
Describe the solution you'd like
A quick and simple fix is below:
#ifdef DEBUG int log_perror = 1; #else int log_perror = 0; #endif