Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting lager_file_backend path to non-default breaks ejabberd_loglevel:set/1 #352

Closed
erszcz opened this issue Jan 13, 2015 · 0 comments
Closed
Labels

Comments

@erszcz
Copy link
Member

erszcz commented Jan 13, 2015

There are two problems with changing a lager_file_backend path in app.config:

  • ejabberd_loglevel:set/1 breaks,
  • there's a discrepancy between ejabberd_app:get_log_path/0 (same as ejabberd_loglevel:log_path/0 seen in the logs below) and the path set in app.config for lager_file_backend.

In other words, there's no consistent (or any properly functioning?) interface for operations teams to set the logging path for MongooseIM to anything other than the default.

Please compare the two console logs. The first one uses the default path log/ejabberd.log and doesn't cause issues:

$ cat etc/app.config
[
 {lager, [
          {handlers, [
                      {lager_console_backend, [info, {lager_default_formatter,[{eol, "\r\n"}]}]},
                      %% file is shadowed by ejabberd.cfg
                      {lager_file_backend, [{file, "log/ejabberd.log"}, {level, info}, {size, 2097152}, {date, "$D0"}, {count, 5}]}
                     ]}
         ]}
].

%% vim: filetype=erlang
17:56:03 erszcz @ x4 : ~/work/esl/mongooseim/rel/mongooseim (master)
$ bin/mongooseimctl live
Exec: /Users/erszcz/work/esl/mongooseim/rel/mongooseim/erts-6.1/bin/erlexec -boot /Users/erszcz/work/esl/mongooseim/rel/mongooseim/releases//mongooseim -embedded -config /Users/erszcz/work/esl/mongooseim/rel/mongooseim/etc/app.config -args_file /Users/erszcz/work/esl/mongooseim/rel/mongooseim/etc/vm.args -- console
Root: /Users/erszcz/work/esl/mongooseim/rel/mongooseim
Erlang/OTP 17 [erts-6.1] [source] [64-bit] [smp:4:4] [async-threads:5] [kernel-poll:true]

2015-01-13 17:56:23.889 [notice] <0.183.0>@lager_file_backend:128 Changed loglevel of log/ejabberd.log to info
2015-01-13 17:56:23.889 [info] <0.7.0> Application lager started on node mongooseim@localhost
2015-01-13 17:56:23.910 [info] <0.7.0> Application mnesia exited with reason: stopped
2015-01-13 17:56:23.930 [info] <0.7.0> Application mnesia started on node mongooseim@localhost
2015-01-13 17:56:23.942 [info] <0.7.0> Application p1_cache_tab started on node mongooseim@localhost
Eshell V6.1  (abort with ^G)
(mongooseim@localhost)1>
(mongooseim@localhost)1> dbg:tracer().
{ok,<0.530.0>}
(mongooseim@localhost)2> dbg:p(all, call).
{ok,[{matched,mongooseim@localhost,247}]}
(mongooseim@localhost)3> dbg:tpl(ejabberd_loglevel, x).
{ok,[{matched,mongooseim@localhost,10},{saved,x}]}
(mongooseim@localhost)4> dbg:tpl(lager, get_loglevel, x).
{ok,[{matched,mongooseim@localhost,1},{saved,x}]}
(mongooseim@localhost)5>
(mongooseim@localhost)5> ejabberd_loglevel:set(5).
(<0.528.0>) call ejabberd_loglevel:set(5)
(<0.528.0>) call ejabberd_loglevel:set(debug)
(<0.528.0>) call ejabberd_loglevel:log_path()
(<0.528.0>) returned from ejabberd_loglevel:log_path/0 -> "log/ejabberd.log"
2015-01-13 17:56:25.303 [notice] <0.183.0>@lager_file_backend:128 Changed loglevel of log/ejabberd.log to debug
(<0.528.0>) returned from ejabberd_loglevel:set/1 -> ok
(<0.528.0>) returned from ejabberd_loglevel:set/1 -> ok
ok
(mongooseim@localhost)6> ejabberd_loglevel:get().
(<0.528.0>) call ejabberd_loglevel:get()
(<0.528.0>) call lager:get_loglevel(lager_console_backend)
(<0.528.0>) returned from lager:get_loglevel/1 -> debug
(<0.528.0>) returned from ejabberd_loglevel:get/0 -> {5,debug}
{5,debug}
(mongooseim@localhost)7>
BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded
       (v)ersion (k)ill (D)b-tables (d)istribution
^C17:56:27 erszcz @ x4 : ~/work/esl/mongooseim/rel/mongooseim (master)
$

While the second one uses adjusted log-somewhere-else/ejabberd.log and returns {error, bad_module} from ejabberd_loglevel:set/1. Moreover, the path returned by ejabberd_loglevel:log_path/0 is not the path configured in app.config.

$ cat etc/app.config
[
 {lager, [
          {handlers, [
                      {lager_console_backend, [info, {lager_default_formatter,[{eol, "\r\n"}]}]},
                      %% file is shadowed by ejabberd.cfg
                      {lager_file_backend, [{file, "log-somewhere-else/ejabberd.log"}, {level, info}, {size, 2097152}, {date, "$D0"}, {count, 5}]}
                     ]}
         ]}
].

%% vim: filetype=erlang
17:57:05 erszcz @ x4 : ~/work/esl/mongooseim/rel/mongooseim (master)
$ bin/mongooseimctl live
Exec: /Users/erszcz/work/esl/mongooseim/rel/mongooseim/erts-6.1/bin/erlexec -boot /Users/erszcz/work/esl/mongooseim/rel/mongooseim/releases//mongooseim -embedded -config /Users/erszcz/work/esl/mongooseim/rel/mongooseim/etc/app.config -args_file /Users/erszcz/work/esl/mongooseim/rel/mongooseim/etc/vm.args -- console
Root: /Users/erszcz/work/esl/mongooseim/rel/mongooseim
Erlang/OTP 17 [erts-6.1] [source] [64-bit] [smp:4:4] [async-threads:5] [kernel-poll:true]

2015-01-13 17:57:09.101 [info] <0.7.0> Application lager started on node mongooseim@localhost
2015-01-13 17:57:09.116 [info] <0.7.0> Application mnesia exited with reason: stopped
2015-01-13 17:57:09.135 [info] <0.7.0> Application mnesia started on node mongooseim@localhost
2015-01-13 17:57:09.151 [info] <0.7.0> Application p1_cache_tab started on node mongooseim@localhost
Eshell V6.1  (abort with ^G)
(mongooseim@localhost)1> dbg:tracer().
{ok,<0.528.0>}
(mongooseim@localhost)2> dbg:p(all, call).
{ok,[{matched,mongooseim@localhost,247}]}
(mongooseim@localhost)3> dbg:tpl(ejabberd_loglevel, x).
{ok,[{matched,mongooseim@localhost,10},{saved,x}]}
(mongooseim@localhost)4> dbg:tpl(lager, get_loglevel, x).
{ok,[{matched,mongooseim@localhost,1},{saved,x}]}
(mongooseim@localhost)5>
(mongooseim@localhost)5> ejabberd_loglevel:set(5).
(<0.526.0>) call ejabberd_loglevel:set(5)
(<0.526.0>) call ejabberd_loglevel:set(debug)
(<0.526.0>) call ejabberd_loglevel:log_path()
(<0.526.0>) returned from ejabberd_loglevel:log_path/0 -> "log/ejabberd.log"
{error,bad_module}
(<0.526.0>) returned from ejabberd_loglevel:set/1 -> {error,bad_module}
(<0.526.0>) returned from ejabberd_loglevel:set/1 -> {error,bad_module}
(mongooseim@localhost)6> ejabberd_loglevel:get().
(<0.526.0>) call ejabberd_loglevel:get()
(<0.526.0>) call lager:get_loglevel(lager_console_backend)
(<0.526.0>) returned from lager:get_loglevel/1 -> debug
(<0.526.0>) returned from ejabberd_loglevel:get/0 -> {5,debug}
{5,debug}
(mongooseim@localhost)7>
BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded
       (v)ersion (k)ill (D)b-tables (d)istribution
^C17:57:19 erszcz @ x4 : ~/work/esl/mongooseim/rel/mongooseim (master)
$

Two obvious solutions come to mind (and maybe some more sophisticated ones exist):

  1. Hide lager settings now visible in app.config, which by being visible suggest the options are tunable, though in fact they aren't.
  2. Discard ejabberd_app:get_log_path/0 and the mechanism it uses to guess the logging path and rely completely on app.config lager settings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants