Uploaded image for project: 'CouchDB'
  1. CouchDB
  2. COUCHDB-2970

config:set("log","level",...) fails to change lager backend levels

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 2.0.0
    • Logging
    • None

    Description

      The following remsh session shows that at first, both config log level and lager_file_backend levels are the same (info), but after we use config to change the level to notice, the lager level remains at info:

      (cloudant@db1.v)26> config:get("log","level").
      "info"
      (cloudant@db1.v)27> gen_event:which_handlers(lager_event).
      [{lager_file_backend,"/var/log/cloudant/cloudant.log"},
       lager_backend_throttle]
      (cloudant@db1.v)28> lager:get_loglevel({lager_file_backend,"/var/log/cloudant/cloudant.log"}).
      info
      (cloudant@db1.v)29> config:set("log","level","notice",false).
      ok
      (cloudant@db1.v)30> lager:get_loglevel({lager_file_backend,"/var/log/cloudant/cloudant.log"}).
      info
      

      The problem occurs because https://github.com/apache/couchdb-couch-log-lager/blob/master/src/couch_log_lager.erl#L67 obtains the handlers from application:get_env(lager, handlers), which returns the a structure defined in sys.config, but it should use gen_event:which_handlers(lager_event), which returns the actual list of handlers:

      (cloudant@db1.v)31> application:get_env(lager, handlers).                                
      {ok,[{lager_file_backend,
               [{file,"/var/log/cloudant/cloudant.log"},
                {formatter,lager_default_formatter},
                {formatter_config,
                    [date," ",time," [",severity,"] ",node," ",pid," ",message,
                     "\n"]}]}]}
      (cloudant@db1.v)32> gen_event:which_handlers(lager_event).                               [{lager_file_backend,"/var/log/cloudant/cloudant.log"},
       lager_backend_throttle]
      

      Attachments

        Activity

          People

            jaydoane Jay Doane
            jaydoane Jay Doane
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: