[erlang-questions] new logger advice requested

Mark Geib mark.geib.44@REDACTED
Fri Apr 12 17:30:10 CEST 2019


Sorry for the long email, but I am looking for suggestions related to dynamically adding
handlers, and/or filters, to the new erlang logger. Some background may help.

I am writing an erlang application to mirror log files from production applications to a central
location. These log files are produced by C#, Java, python, etc. Currently I am using
td-agent on each host to tail the log files and write a message to a rabbitmq broker where
the message includes the log file line, and the full path of the tailed log file. My erlang 
application receives all these amqp messages and writes the log lines to a location derived
from the full path of the original file. I simply keep track of the file paths, and when I see a 
new one create a new gen_server to handle the lines for that file. Thereby I need no
configuration, except the broker connection info of course. Currently I am simply appending
to the file as each line is forwarded to the gen_server. Works great, but not file rotation, etc.

I need advice as to how I may dynamically add, and configure, a new handler as each gen_server
is created and configure it to write to the correct derived file path, and only write log messages from 
the  gen_server adding the handler. So in each worker gen_server handling a log file I want to be
able to simple call logger:info() and have the log messages from that one gen_server written 
to the configured file, same for all the other gen_servers of course. This allows me to use
the built-in file rotation, etc. all for free..

Thanks for any suggestions,

Mark.





More information about the erlang-questions mailing list