Hex version API docs CircleCI REUSE status

NervesLogging forwards log messages from the Linux kernel and syslog to the Elixir logger. It's used with Nerves so that all log messages pass through one place.

Messages logged by NervesLogging copy the "Syslog" severity directly to the Logger level. This means that if the kernel's level is "Error", the Elixir level will be :error. Since Elixir 1.11 and later have the same log levels as Syslog, this mapping is 1:1.

NervesLogging adds the following metadata to the log messages:

  • :facility - the facility of the log message
  • :application - either :$kmsg or :$syslog

See the Elixir Logger documentation for reducing what's logged if the system logs become too noisy. Some examples:

# Reduce logging for both syslog and kernel logs
Logger.put_application_level(:nerves_logging, :error)

# Adjust logging for kernel logs
Logger.put_module_level(NervesLogging.KmsgTailer, :error)

# Adjust logging for syslog logs
Logger.put_module_level(NervesLogging.SyslogTailer, :error)

Using

There's no configuration. If you're using Nerves, you should get this application by default since it's a dependency of Nerves.Runtime.

Important: If you're not using Nerves.Runtime, you must add [NervesLogging.KmsgTailer, NervesLogging.SyslogTailer] to a supervision tree. This makes it possible to coordinate starting or restarting these Linux log monitors in coordination with your logger. The KmsgTailer logs historic kernel messages since boot when it starts up so you probably want a :one_for_one strategy to minimize its restarts due to other GenServer crashes.

License

All original source code in this project is licensed under Apache-2.0.

Additionally, this project follows the REUSE recommendations and labels so that licensing and copyright are clear at the file level.

Exceptions to Apache-2.0 licensing are:

  • Configuration and data files are licensed under CC0-1.0
  • Documentation is CC-BY-4.0