Logging from a NIF

Hi there,

since erl_nif doesn’t seem to provide an interface to the logger, I’m wondering what’s the best way to accomplish logging from a NIF. I thought about having a ‘global’ process or a pool of them that I could send messages to and that would call the logger functions. But maybe there’s a way to avoid such a proxy?

2 Likes

As far as I know that is the best way. The Erlang Run-time System uses that exact approach to send log messages, it is implemented in logger_proxy.

2 Likes

Ok, thanks. Can I use this logger_proxy or should I implement my own? Maybe there are some libraries for that?

You need to implement your own, it is not an exposed API. I don’t know of any libraries that can help with it.

1 Like