Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set format on backends? #55

Open
zhaoyi0113 opened this issue Aug 14, 2018 · 2 comments
Open

How to set format on backends? #55

zhaoyi0113 opened this issue Aug 14, 2018 · 2 comments

Comments

@zhaoyi0113
Copy link

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"
@isaacsanders
Copy link

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"

@krisleech
Copy link

krisleech commented Oct 11, 2024

Is it possible to pass a formater like LoggerJSON.Formatters.Elastic as I want JSON logs to disk.

I already have this:

config :logger, :default_handler,
  metadata: :all,
  formatter: {LoggerJSON.Formatters.Elastic, metadata: :all}

But I still get non-JSON logs. Thanks!

UPDATE: nevermind, I see it is out of scope 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants