assert(params);
assert(exit_status);
+ /* This should be mostly redundant, as the log level is also passed as an argument of the executor,
+ * and is already applied earlier. Just for safety. */
if (context->log_level_max >= 0)
log_set_max_level(context->log_level_max);
if (r < 0)
return r;
+ /* This is also passed to executor as an argument. So, the information should be redundant in general.
+ * But, let's keep this as is for consistency with other elements of ExecContext. See exec_spawn(). */
r = serialize_item_format(f, "exec-context-log-level-max", "%d", c->log_level_max);
if (r < 0)
return r;
if (r < 0)
return r;
} else if ((val = startswith(l, "exec-context-log-level-max="))) {
+ /* See comment in serialization. */
r = safe_atoi(val, &c->log_level_max);
if (r < 0)
return r;
if (r < 0)
return log_unit_error_errno(unit, r, "Failed to set O_CLOEXEC on serialized fds: %m");
- r = log_level_to_string_alloc(log_get_max_level(), &log_level);
+ /* If LogLevelMax= is specified, then let's use the specified log level at the beginning of the
+ * executor process. To achieve that the specified log level is passed as an argument, rather than
+ * the one for the manager process. */
+ r = log_level_to_string_alloc(context->log_level_max >= 0 ? context->log_level_max : log_get_max_level(), &log_level);
if (r < 0)
return log_unit_error_errno(unit, r, "Failed to convert log level to string: %m");