logger_file_backend icon indicating copy to clipboard operation
logger_file_backend copied to clipboard

How to set format on backends?

Open zhaoyi0113 opened this issue 6 years ago • 2 comments

I am not sure whether this is an issue or a question.

Below is my configuration which works fine:

config :logger, backends: [{LoggerFileBackend, :error_log}]

Now I want to add a format for the log and I am not sure how to do that. I tried a few configuration but none of them work as below. How can I configure the format?

config :logger, backends: [{LoggerFileBackend, :error_log, format: "\n$date $time $metadata $levelpad$message\n"}]

config :logger, backends: [{LoggerFileBackend, :error_log}],
   format: "\n$date $time $metadata $levelpad$message\n"

zhaoyi0113 avatar Aug 14 '18 00:08 zhaoyi0113

The second item in the backend declaration pair is the name of the backend, in the case of LoggerFileBackend.

In order to configure the LoggerFileBackend : error_log , for example, one could do the following:

config :logger, backends: [{LoggerFileBackend, :error_log}]

config :logger, :error_log,
  format: "\n$date $time $metadata $levelpad$message\n"

isaacsanders avatar Aug 23 '18 16:08 isaacsanders