roidrage/lograge

Remove timestamp & log level prefix in production mode

steverob opened this issue · 2 comments

I'm using the JSON formatter with the following configuration:

Rails.application.configure do
  config.lograge.enabled = true
  config.lograge.formatter = Lograge::Formatters::Json.new
  config.lograge.custom_options = lambda do |event|
    {
      time: event.time,
      host: event.payload[:host],
      ip_addr: event.payload[:ip_addr],
      subdomain: event.payload[:subdomain],
      params: event.payload[:params],
      ddsource: ["ruby"]
    }
  end
end

It works great in development mode but in production there is this prefix that gets added to the JSON message. This messes up badly with downstream log parsers. I'm not able to figure out how to remove this. We're running Rails 5.2.1

I, [2020-06-21T20:06:28.730211 #6278]  INFO -- : {"method":"GET","path":"/306/create/check_po_requirement","format":"json","controller":"FleetProfileController","action":"check_po_requirement","status":200,"duration":5.24,"view":0.16,"db":2.11,"time":"2020-06-21 20:06:28 +0000","host":"mywebsite.net","ip_addr":"99.87.232.240","subdomain":"abcd","params":{"controller":"fleet_profile","action":"check_po_requirement","td_id":"306","scenario":"create"},"ddsource":["ruby"]}

I should have searched deeper. Solution here: #84

@steverob can you share how the config.lograge looks like? 🙏