log-tag <string>
Override syslog log tag set globally or per-proxy using "log-tag" directive.
-on <step> [format <fmt>] [sd <sd_fmt>]
+on <step> [drop] [format <fmt>] [sd <sd_fmt>]
Override the log-format string normally used to build the log line at
<step> logging step. <fmt> is used to override "log-format" or
"error-log-format" strings (depending on the <step>) whereas <sd_fmt> is
- used to override "log-format-sd" string. Possible values for <step> are:
+ used to override "log-format-sd" string (both can be combined).
+
+ "drop" special keyword may be used to specify that no log should be
+ emitted for the given <step>. It takes precedence over "format" and
+ "sd" if previously defined.
+
+ Possible values for <step> are:
- "accept" : override log-format if the log is generated right after
frontend conn was accepted
log-tag "custom-tag"
on error format "%ci: error"
+ on connect drop
on any sd "custom-sd"
listen myproxy
LOG_ORIG_TXN_CLOSE, /* during stream termination */
};
+/* log profile step flags */
+enum log_ps_flags {
+ LOG_PS_FL_NONE = 0,
+ LOG_PS_FL_DROP, /* don't emit log for this step */
+};
+
struct log_profile_step {
struct lf_expr logformat;
struct lf_expr logformat_sd;
+ enum log_ps_flags flags; /* LOG_PS_FL_* */
};
struct log_profile {
barrier b4 sync
} -start
+syslog Slg4 -level info {
+ recv
+ #rfc5424, logprof3, tcp error (other steps should be dropped)
+ expect ~ ".* custom ${h1_pid} .* error"
+ barrier b4 sync
+} -start
+
haproxy h1 -conf {
defaults
timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
log udp@${Slg1_addr}:${Slg1_port} format rfc5424 local0
log udp@${Slg2_addr}:${Slg2_port} format rfc5424 profile logprof1 local0
log udp@${Slg3_addr}:${Slg3_port} format rfc5424 profile logprof2 local0
+ log udp@${Slg4_addr}:${Slg4_port} format rfc5424 profile logprof3 local0
default_backend be_tcp
on error format "error"
on any format "%OG"
+ log-profile logprof3
+ on error format "error"
+ on any drop
+
backend be
mode http
server app1 ${s1_addr}:${s1_port}
step = prof->any;
if (ctx && ctx->sess && step) {
+ if (step->flags & LOG_PS_FL_DROP)
+ goto end; // skip logging
+
/* we may need to rebuild message using lf_expr from profile
* step and possibly sd metadata if provided on the profile
*/
{
lf_expr_init(&lprof_step->logformat);
lf_expr_init(&lprof_step->logformat_sd);
+ lprof_step->flags = LOG_PS_FL_NONE;
}
static inline void log_profile_step_free(struct log_profile_step *lprof_step)
cur_arg = 2;
while (*(args[cur_arg]) != 0) {
+ /* drop logs ? */
+ if (strcmp(args[cur_arg], "drop") == 0) {
+ if (cur_arg != 2)
+ break;
+ (*target_step)->flags |= LOG_PS_FL_DROP;
+ cur_arg += 1;
+ continue;
+ }
/* regular format or SD (structured-data) one? */
- if (strcmp(args[cur_arg], "format") == 0)
+ else if (strcmp(args[cur_arg], "format") == 0)
target_lf = &(*target_step)->logformat;
else if (strcmp(args[cur_arg], "sd") == 0)
target_lf = &(*target_step)->logformat_sd;
else
break;
+ (*target_step)->flags &= ~LOG_PS_FL_DROP;
+
/* parse and assign logformat expression */
lf_expr_deinit(target_lf); /* if already configured */
cur_arg += 2;
}
if (cur_arg == 2 || *(args[cur_arg]) != 0) {
- ha_alert("parsing [%s:%d] : '%s %s' expects 'format' and/or 'sd'.\n",
+ ha_alert("parsing [%s:%d] : '%s %s' expects 'drop', 'format' or 'sd'.\n",
file, linenum, args[0], args[1]);
err_code |= ERR_ALERT | ERR_FATAL;
goto out;