actindi / act-fluent-logger-rails

Fluent logger
MIT License
118 stars 72 forks source link

Timestamp in logs ? #46

Open c0ze opened 6 years ago

c0ze commented 6 years ago

I'm using Rails 5, my configuration is :

    config.log_level = :info
    config.logger = ActFluentLoggerRails::Logger.new(
      settings: {
        host: ENV['FLUENTD_HOST'],
        port: 24224,
        tag: "myApp-#{Rails.env}",
        messages_type: 'string',
        severity_key: 'level'
      },
      log_tags: {
        ip: :ip,
        ua: :user_agent
      })
    # buggy for now
    # https://github.com/actindi/act-fluent-logger-rails/issues/41
    # uid: ->(request) { request.session[:uid] }
    config.lograge.enabled = true
    config.lograge.formatter = Lograge::Formatters::Json.new

The logs I get follows :

{"method":"GET","path":"/health","format":"html","controller":"ApplicationController","action":"health","status":200,"duration":2.53,"view":0.0,"db":0.76}
{"method":"GET","path":"/health","format":"html","controller":"ApplicationController","action":"health","status":200,"duration":2.16,"view":0.0,"db":0.71}
{"method":"GET","path":"/health","format":"html","controller":"ApplicationController","action":"health","status":200,"duration":2.02,"view":0.0,"db":0.65}

It seems it is ignoring ua and ip. What could be the issue ?

Also, how can I add timestamps to the logs ?