gelf v0.1.0 Gelf

GELF Logger Backend

Example

config :logger
  utc_log: true,
  backends: [:console, Gelf]

config :logger, Gelf,
  level: :debug,
  host: "localhost",
  port: 12201,
  compress: :zlib,
  app: "my_app_name",
  metadata: [:file, :line],
  chunk_size: 1500

Options

  • :level - (atom) minimum allowed log level. Defaults to :debug. That is, by default everything will be logged.

  • :host - (string) hostname of the gelf udp server. Defaults to "localhost".

  • :port - (integer) the port on which the gelf udp server is listening. Defaults 12201.

  • :compress - (atom) the compression method to be used to compress the data. Valid values are :gzip, :zlib and :none. Defaults to :zlib.

  • :app - (string) name of your app. The host field in the message will be set to this value. Defaluts to current node name.

  • :metadata - ([atom]) list of metadata fields that should be added to the message. The fields are added as additional field in the message(keys will be prefixed with _). Defaults to [].

  • :chunk_size - (integer) Maximum size of a single message in bytes. If the log message is bigger than chunk_size, it will be split into multiple chunks. The server will construct the message from the chunks. Set it to the maximum bytes that can be transferred safely as a single datagram packet. Defaults to 1500.

All the options(except chunk_size) can be changed during the runtime using Logger.configure_backend/2.

Notes

Make sure to set the utc_log option to true in logger. The backend just receives a tuple without any timezone information. During the conversion to epoch, it assumes the date is in utc format. Not enabling utc_log will lead to wrong timestamp value.