<div dir="ltr">Hi Nicolas,<div><br></div><div>to set the module level in configuration, use the kernel parameter 'logger', and the term {module_level,Level,Modules}, for example, to set debug level for modules x, y and z:</div><div><br></div><div>sys.config:</div><div>[{kernel,[{logger,[{module_level,debug,[x,y,z]}]}]}].<br></div><div><br></div><div>Note that you must use the log macros for logging for this to work. Or, alternatively, add mfa=>{Module,Function,Arity} to the metadata for each log event.</div><div><br></div><div>Unfortunately, there is no built-in way to get the module name only into each log message, but if you use the marcos (or add mfa yourself) you can get Module:Fun/Arity in your log messages by adding the atom 'mfa' to your formatter template, e.g.</div><div><div><br></div><div>1> logger:update_formatter_config(default,template,[time," ",level,", ",mfa,": ",msg,"\n"]). </div><div>ok</div><div>2> logger:debug("hello world",#{mfa=>{x,f,1}}).</div><div>2018-09-03T15:37:35.577776+02:00 debug, x:f/1: hello world<br></div></div><div><br></div><div>BR</div><div>/siri</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr">Den ons. 29. aug. 2018 kl. 18:07 skrev Nicolas Martyanoff <<a href="mailto:khaelin@gmail.com">khaelin@gmail.com</a>>:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I have been trying to use the new logger application, and I am not sure about<br>
the way I am supposed to configure it for my needs (keep in mind that I am an<br>
Erlang beginner, hoping to use Erlang in production someday).<br>
<br>
During development of a "library", i.e. an OTP application used by the program<br>
I am working on, I need to see all logs related to the modules which are part<br>
of the OTP application. However I cannot see how to set the log level to<br>
`debug` for these modules only (and not globally with `{logger_level,<br>
debug}`). Ideally, there would be a way to configure it in a local sys.config<br>
to get this effect only during development, without having to do it<br>
programmatically in every module I work on.<br>
<br>
More importantly, I can't seem to find a way to include the name of the module<br>
in log messages, either in the formatter template or anywhere else. Am I<br>
supposed to add it manually to every single logger message I write ?<br>
<br>
I am just trying to find a simple way to add log instructions to the code I<br>
write, with the possibility to control which ones are printed depending on the<br>
environment (local library development, application development, tests,<br>
production...) using settings in sys.config.<br>
<br>
Thank you in advance.<br>
<br>
-- <br>
Nicolas Martyanoff<br>
<a href="http://snowsyn.net" rel="noreferrer" target="_blank">http://snowsyn.net</a><br>
<a href="mailto:khaelin@gmail.com" target="_blank">khaelin@gmail.com</a><br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</blockquote></div>