-
The documentation states that if
Would result in a single appender, going to standard out. However, when using the rails server (in development, for example), a default appender is still added, so we see duplicate logs (one :json format, one :color format). |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments
-
Make sure you are setting |
Beta Was this translation helpful? Give feedback.
-
Changes have been made in master to replace several builtin Rails subscribers instead of patching them. It should help with the ongoing patching issues and loading order. |
Beta Was this translation helpful? Give feedback.
-
@reidmorrison thanks for the comments. I've tried master and doesn't see a change with respect to this issue. I should be more clear though, I've conflated two things that I'm realizing aren't necessarily related. ExpectationLet's say the user's goal is "I want to log to standard out and that's it". The language in the docs on this indicate that the following would result in only a single appender, going to STDOUT.
BehaviorIn reality, after the application is configured, there are two appenders. In our example, for each application line logged, we would see two printed to STDOUT, one in This is due to the Overwriting # workaround for https://github.com/rocketjob/rails_semantic_logger/issues/66
# which would result in duplicate logs on STDOUT if `rails s` is used
# if defined?(Rails::Server)
# module Rails #:nodoc:
# class Server #:nodoc:
# private
# def log_to_stdout
# # SemanticLogger.add_appender(io: $stdout, formatter: :color)
# end
# end
# end
# end Running with another application server (e.g. CommentsAfter thinking further, this issue is unrelated to Semantic Logger's handling of the However, I believe the user confusion still remains. IMO, at least some additional clarity in the documentation is needed to address this issue. In other words, it is probably unreasonable to expect Semantic Logger's definition of If we wanted to address with more than just documentation, one idea is to introduce an additional option to disable the rails server STDOUT appender...
|
Beta Was this translation helpful? Give feedback.
-
Logging to standard out is controlled by Rails. To turn it off, it needs to be run as a daemon in the development environment, or looking at the code it turns off automatically in non-development environments. We run puma instead of starting a rails server: If you run |
Beta Was this translation helpful? Give feedback.
-
We do the same, however some of our devs use I think it would be worth adding a sentence or two to this effect in the docs here: http://rocketjob.github.io/semantic_logger/rails.html#disable-default-rails-file-logging At any rate, I'm glad this issue discussion is here now for any others running into this. Thanks! |
Beta Was this translation helpful? Give feedback.
-
Documentation updated with a note about this behavior in Rails itself |
Beta Was this translation helpful? Give feedback.
-
Use |
Beta Was this translation helpful? Give feedback.
Use
rails s --no-log-to-stdout
to disable default stdout log in development.