Integrating a syslog-based logging framework with my Phoenix project

Hello all,
I’m new to Elixir/Phoenix. I want to replace the default logger module with syslog to be compatible with the syslog protocol. My Phoenix project has 2 apps/sub-modules. With respect to the logger hex documentation I’ve placed the handler in the main project’s config.exs :

config :app_a, :logger, [ {:handler, :test_handler, :syslog_logger_h, configuration = %{}} ]

config :app_b, :logger, [ {:handler, :test_handler, :syslog_logger_h, configuration = %{}} ]

Also, each app’s mix.exs has the following dependency:

defp deps do [ {:syslog, github: "schlagert/syslog"} ]

Each apps Application.start() explicitly uses the add_handlers callback to enable the syslog handler (e.g. :logger.add_handlers(:app_a) ). I use netct to listen for incoming syslog messages with the following command: ncat -tul 514 (514 being the default syslog port). I can see each apps syslog messages if they are enabled individually.

I could not get both applications to send their syslog messages at the same time. Only one of the applications’ syslog messages were displayed. Any help is much appreciated.

Hello folks,
This was resolved by using nc instead of ncat. The following Github issue was useful to this end:

I used the following as a solution to the stated problem: nc -kluvw 0 localhost 514

1 Like