Lager is a popular logging framework for Erlang applications. To get it working with Cowboy (assuming you’re using erlang.mk), you need to add it as a dependency to your Makefile:
DEPS = cowboy lager
and then add the parse transform to the options for erlc (as shown here):
include erlang.mk
ERLC_OPTS += +'{parse_transform, lager_transform}'
(alternatively, you could add a compile header to each file that needs it). You also need to add lager to your app.src file:
{applications, [
kernel,
stdlib,
cowboy,
lager
]},
]}.
so that it is started as part of your release. You can find an example repo here.