mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-06 07:07:04 +02:00
MEDIUM: connection: Add option to disable legacy error log
In case of connection failure, a dedicated error message is output, following the format described in section "Error log format" of the documentation. These messages cannot be configured through a log-format option. This patch adds a new option, "dontloglegacyconnerr", that disables those error logs when set, and "replaces" them by a regular log line that follows the configured log-format (thanks to a call to sess_log in session_kill_embryonic). The new fc_conn_err sample fetch allows to add the legacy error log information into a regular log format. This new option is unset by default so the logging logic will remain the same until this new option is used.
This commit is contained in:
parent
98b930d043
commit
4a6328f066
@ -9033,6 +9033,23 @@ no option logasap
|
||||
logging.
|
||||
|
||||
|
||||
option dontloglegacyconnerr
|
||||
no option dontloglegacyconnerr
|
||||
Enable or disable dedicated connection error logging.
|
||||
May be used in sections : defaults | frontend | listen | backend
|
||||
yes | yes | yes | no
|
||||
Arguments : none
|
||||
|
||||
In case of connection error, if the option is disabled, a log line following
|
||||
the format described in section 8.2.6, the legacy format, will be emitted.
|
||||
Otherwise, a log line following the configured log-format for the listener
|
||||
will be emitted. The error code and the corresponding message found in the
|
||||
error log can be added to a log-format thanks to the "fc_conn_err" and
|
||||
"fc_conn_err_str" sample fetches.
|
||||
|
||||
See also : "option httpslog" and section 8 about logging.
|
||||
|
||||
|
||||
option mysql-check [ user <username> [ { post-41 | pre-41 } ] ]
|
||||
Use MySQL health checks for server testing
|
||||
May be used in sections : defaults | frontend | listen | backend
|
||||
@ -20984,7 +21001,9 @@ protocol header, HAProxy will log the event using a shorter, fixed line format.
|
||||
By default, logs are emitted at the LOG_INFO level, unless the option
|
||||
"log-separate-errors" is set in the backend, in which case the LOG_ERR level
|
||||
will be used. Connections on which no data are exchanged (e.g. probes) are not
|
||||
logged if the "dontlognull" option is set.
|
||||
logged if the "dontlognull" option is set. If the "dontloglegacyconnerr" option
|
||||
is set, those messages are not emitted and a line following the configured
|
||||
log-format is emitted instead.
|
||||
|
||||
The format looks like this :
|
||||
|
||||
|
@ -95,7 +95,8 @@ enum PR_SRV_STATE_FILE {
|
||||
#define PR_O_FF_ALWAYS 0x00002000 /* always set x-forwarded-for */
|
||||
#define PR_O_PERSIST 0x00004000 /* server persistence stays effective even when server is down */
|
||||
#define PR_O_LOGASAP 0x00008000 /* log as soon as possible, without waiting for the stream to complete */
|
||||
/* unused: 0x00010000 */
|
||||
#define PR_O_NOLGCYCONNERR 0x00010000 /* log a dedicated error log message in case of connection failure instead of the legacy connection error message */
|
||||
|
||||
#define PR_O_CHK_CACHE 0x00020000 /* require examination of cacheability of the 'set-cookie' field */
|
||||
#define PR_O_TCP_CLI_KA 0x00040000 /* enable TCP keep-alive on client-side streams */
|
||||
#define PR_O_TCP_SRV_KA 0x00080000 /* enable TCP keep-alive on server-side streams */
|
||||
|
@ -72,6 +72,7 @@ const struct cfg_opt cfg_opts[] =
|
||||
{ "http-ignore-probes", PR_O_IGNORE_PRB, PR_CAP_FE, 0, PR_MODE_HTTP },
|
||||
{ "prefer-last-server", PR_O_PREF_LAST, PR_CAP_BE, 0, PR_MODE_HTTP },
|
||||
{ "logasap", PR_O_LOGASAP, PR_CAP_FE, 0, 0 },
|
||||
{ "dontloglegacyconnerr", PR_O_NOLGCYCONNERR, PR_CAP_FE, 0, 0 },
|
||||
{ "nolinger", PR_O_TCP_NOLING, PR_CAP_FE | PR_CAP_BE, 0, 0 },
|
||||
{ "persist", PR_O_PERSIST, PR_CAP_BE, 0, 0 },
|
||||
{ "srvtcpka", PR_O_TCP_SRV_KA, PR_CAP_BE, 0, 0 },
|
||||
|
@ -357,14 +357,20 @@ static void session_kill_embryonic(struct session *sess, unsigned int state)
|
||||
conn->err_code = CO_ER_SSL_TIMEOUT;
|
||||
}
|
||||
|
||||
session_prepare_log_prefix(sess);
|
||||
err_msg = conn_err_code_str(conn);
|
||||
if (err_msg)
|
||||
send_log(sess->fe, level, "%s: %s\n", trash.area,
|
||||
err_msg);
|
||||
else
|
||||
send_log(sess->fe, level, "%s: unknown connection error (code=%d flags=%08x)\n",
|
||||
trash.area, conn->err_code, conn->flags);
|
||||
if (sess->fe->options & PR_O_NOLGCYCONNERR) {
|
||||
/* Display a log line following the configured log-format. */
|
||||
sess_log(sess);
|
||||
}
|
||||
else {
|
||||
session_prepare_log_prefix(sess);
|
||||
err_msg = conn_err_code_str(conn);
|
||||
if (err_msg)
|
||||
send_log(sess->fe, level, "%s: %s\n", trash.area,
|
||||
err_msg);
|
||||
else
|
||||
send_log(sess->fe, level, "%s: unknown connection error (code=%d flags=%08x)\n",
|
||||
trash.area, conn->err_code, conn->flags);
|
||||
}
|
||||
}
|
||||
|
||||
/* kill the connection now */
|
||||
|
Loading…
Reference in New Issue
Block a user