[erlang-questions] lager runtime configuration changes
Andrew Thompson
andrew@REDACTED
Sat Feb 11 00:58:26 CET 2012
On Fri, Feb 10, 2012 at 07:22:01PM +0000, Motiejus Jakštys wrote:
> Hello,
>
> Sometimes hot changing lager loglevel is not sufficient. Let's say I want to
> add a lager backend while system is running (actually, change anything that's
> in lager config file). What should I run/execute, after the change/if I know
> the new params?
>
> {lager, [
> {handlers, [
> {lager_console_backend, info},
> {lager_file_backend, [
> {"error.log", error, 10485760, "$D0", 5}, % assume I just created this
> {"console.log", info, 10485760, "$D0", 5}
> ]}
> ]}
> ]}.
>
> One way would be application:set_env/3. How unsafe is it?
Lager is really just gen_event at its core, you can just add/remove
handlers manually if you wish, at runtime:
gen_event:add_handler(lager_event, {lager_file_backend, "error.log"},
{"error.log", error, 0485760, "$D0", 5})
You can also use which_handlers() and delete_handler() to see what's
installed and remove one.
That said, it might be nice to have a little more runtime flexibility at
some point that would make this easier.
Andrew
More information about the erlang-questions
mailing list