docs: add log docs

This commit is contained in:
Zaiming (Stone) Shi 2024-02-27 09:08:34 +01:00
parent bb6a95bae8
commit ef99037335
7 changed files with 62 additions and 15 deletions

View File

@ -0,0 +1,20 @@
## EMQX provides support for two primary log handlers: `file` and `console`, with an additional `audit` handler specifically designed to always direct logs to files.
## The system's default log handling behavior can be configured via the environment variable `EMQX_DEFAULT_LOG_HANDLER`, which accepts the following settings:
##
## - `file`: Directs log output exclusively to files.
## - `console`: Channels log output solely to the console.
##
## It's noteworthy that `EMQX_DEFAULT_LOG_HANDLER` is set to `file` when EMQX is initiated via systemd `emqx.service` file.
## In scenarios outside systemd initiation, `console` serves as the default log handler.
## Read more about configs here: {{ emqx_configuration_doc_log }}
log {
# file {
# level = warning
# }
# console {
# level = warning
# }
}

View File

@ -116,7 +116,8 @@ roots() ->
?R_REF("log"), ?R_REF("log"),
#{ #{
translate_to => ["kernel"], translate_to => ["kernel"],
importance => ?IMPORTANCE_HIGH importance => ?IMPORTANCE_HIGH,
desc => ?DESC(log_root)
} }
)}, )},
{rpc, {rpc,
@ -1234,9 +1235,10 @@ tr_cluster_discovery(Conf) ->
{Strategy, filter(cluster_options(Strategy, Conf))}. {Strategy, filter(cluster_options(Strategy, Conf))}.
log_handler_common_confs(Handler, Default) -> log_handler_common_confs(Handler, Default) ->
%% we rarely support dynamic defaults like this %% We rarely support dynamic defaults like this.
%% for this one, we have build-time default the same as runtime default %% For this one, we have build-time default the same as runtime default so it's less tricky
%% so it's less tricky %% Buildtime default: "" (which is the same as "file")
%% Runtime default: "file" (because .service file sets EMQX_DEFAULT_LOG_HANDLER to "file")
EnableValues = EnableValues =
case Handler of case Handler of
console -> ["console", "both"]; console -> ["console", "both"];

View File

@ -604,7 +604,7 @@ check_license() {
return 0 return 0
fi fi
key_license="${EMQX_LICENSE__KEY:-$(get_boot_config 'license.key')}" key_license="${EMQX_LICENSE__KEY:-$(get_boot_config 'license.key' || echo '')}"
if [[ -n "$key_license" && ("$key_license" != "undefined") ]]; then if [[ -n "$key_license" && ("$key_license" != "undefined") ]]; then
call_nodetool check_license_key "$key_license" call_nodetool check_license_key "$key_license"

20
mix.exs
View File

@ -722,7 +722,8 @@ defmodule EMQXUmbrella.MixProject do
defp template_vars(release, release_type, :bin = _package_type, edition_type) do defp template_vars(release, release_type, :bin = _package_type, edition_type) do
[ [
emqx_default_erlang_cookie: default_cookie(), emqx_default_erlang_cookie: default_cookie(),
emqx_configuration_doc: emqx_configuration_doc(edition_type), emqx_configuration_doc: emqx_configuration_doc(edition_type, :root),
emqx_configuration_doc_log: emqx_configuration_doc(edition_type, :log),
platform_data_dir: "data", platform_data_dir: "data",
platform_etc_dir: "etc", platform_etc_dir: "etc",
platform_plugins_dir: "plugins", platform_plugins_dir: "plugins",
@ -745,7 +746,8 @@ defmodule EMQXUmbrella.MixProject do
defp template_vars(release, release_type, :pkg = _package_type, edition_type) do defp template_vars(release, release_type, :pkg = _package_type, edition_type) do
[ [
emqx_default_erlang_cookie: default_cookie(), emqx_default_erlang_cookie: default_cookie(),
emqx_configuration_doc: emqx_configuration_doc(edition_type), emqx_configuration_doc: emqx_configuration_doc(edition_type, :root),
emqx_configuration_doc_log: emqx_configuration_doc(edition_type, :log),
platform_data_dir: "/var/lib/emqx", platform_data_dir: "/var/lib/emqx",
platform_etc_dir: "/etc/emqx", platform_etc_dir: "/etc/emqx",
platform_plugins_dir: "/var/lib/emqx/plugins", platform_plugins_dir: "/var/lib/emqx/plugins",
@ -779,11 +781,17 @@ defmodule EMQXUmbrella.MixProject do
end end
end end
defp emqx_configuration_doc(:enterprise), defp emqx_configuration_doc(:enterprise, :root),
do: "https://docs.emqx.com/en/enterprise/v5.0/configuration/configuration.html" do: "https://docs.emqx.com/en/enterprise/latest/configuration/configuration.html"
defp emqx_configuration_doc(:community), defp emqx_configuration_doc(:enterprise, :log),
do: "https://www.emqx.io/docs/en/v5.0/configuration/configuration.html" do: "https://docs.emqx.com/en/enterprise/latest/configuration/logs.html"
defp emqx_configuration_doc(:community, :root),
do: "https://www.emqx.io/docs/en/latest/configuration/configuration.html"
defp emqx_configuration_doc(:community, :log),
do: "https://www.emqx.io/docs/en/latest/configuration/logs.html"
defp emqx_schema_mod(:enterprise), do: :emqx_enterprise_schema defp emqx_schema_mod(:enterprise), do: :emqx_enterprise_schema
defp emqx_schema_mod(:community), do: :emqx_conf_schema defp emqx_schema_mod(:community), do: :emqx_conf_schema

View File

@ -352,16 +352,19 @@ overlay_vars(cloud, PkgType, Edition) ->
overlay_vars_edition(ce) -> overlay_vars_edition(ce) ->
[ [
{emqx_schema_mod, emqx_conf_schema}, {emqx_schema_mod, emqx_conf_schema},
{is_enterprise, "no"},
{emqx_configuration_doc, {emqx_configuration_doc,
"https://www.emqx.io/docs/en/v5.0/configuration/configuration.html"}, "https://www.emqx.io/docs/en/latest/configuration/configuration.html"},
{is_enterprise, "no"} {emqx_configuration_doc_log, "https://www.emqx.io/docs/en/latest/configuration/logs.html"}
]; ];
overlay_vars_edition(ee) -> overlay_vars_edition(ee) ->
[ [
{emqx_schema_mod, emqx_enterprise_schema}, {emqx_schema_mod, emqx_enterprise_schema},
{is_enterprise, "yes"},
{emqx_configuration_doc, {emqx_configuration_doc,
"https://docs.emqx.com/en/enterprise/v5.0/configuration/configuration.html"}, "https://docs.emqx.com/en/enterprise/latest/configuration/configuration.html"},
{is_enterprise, "yes"} {emqx_configuration_doc_log,
"https://docs.emqx.com/en/enterprise/latest/configuration/logs.html"}
]. ].
%% vars per packaging type, bin(zip/tar.gz/docker) or pkg(rpm/deb) %% vars per packaging type, bin(zip/tar.gz/docker) or pkg(rpm/deb)

View File

@ -1,5 +1,18 @@
emqx_conf_schema { emqx_conf_schema {
log_root.desc =
"""~
EMQX provides support for two primary log handlers: `file` and `console`, with an additional `audit` handler specifically designed to always direct logs to files.
The system's default log handling behavior can be configured via the environment variable `EMQX_DEFAULT_LOG_HANDLER`, which accepts the following settings:
- `file`: Directs log output exclusively to files.
- `console`: Channels log output solely to the console.
It's noteworthy that `EMQX_DEFAULT_LOG_HANDLER` is set to `file` when EMQX is initiated via systemd's `emqx.service` file.
In scenarios outside systemd initiation, `console` serves as the default log handler."""
log_root.label = log
common_handler_drop_mode_qlen.desc: common_handler_drop_mode_qlen.desc:
"""When the number of buffered log events is larger than this value, the new log events are dropped. """When the number of buffered log events is larger than this value, the new log events are dropped.
When drop mode is activated or deactivated, a message is printed in the logs.""" When drop mode is activated or deactivated, a message is printed in the logs."""

View File

@ -239,6 +239,7 @@ superset
sys sys
sysmem sysmem
sysmon sysmon
systemd
tcp tcp
ticktime ticktime
timeseries timeseries