Log Formats

Built-in Formats

Log files loaded into lnav are parsed based on formats defined in configuration files. Many formats are already built in to the lnav binary and you can define your own using a JSON file. When loading files, each format is checked to see if it can parse the first few lines in the file. Once a match is found, that format will be considered that files format and used to parse the remaining lines in the file. If no match is found, the file is considered to be plain text and can be viewed in the “text” view that is accessed with the t key.

The following log formats are built into lnav:

NameTable NameDescription
Common Access Logaccess_logThe default web access log format for servers like Apache.
Amazon ALB logalb_logLog format for Amazon Application Load Balancers
Generic Blockblock_logA generic format for logs, like cron, that have a date at the start of a block.
Bunyan logbunyan_logBunyan JSON logging library for node.js
Caddy log formatcaddy_log 
Candlepin log formatcandlepin_logLog format used by Candlepin registration system
Yum choose_repo Logchoose_repo_logThe log format for the yum choose_repo tool.
Cloudflare Access Logcloudflare_json_logCloudflare Enterprise detailed logs of metadata
CloudVM Ram Logcloudvm_ram_logPeriodic dumps of ram sizes
CUPS log formatcups_logLog format used by the Common Unix Printing System
Dpkg Logdpkg_logThe debian dpkg log.
ecsecs_logElastic Common Schema (ECS) defines a common set of fields for ingesting data into Elasticsearch including log records
Amazon ELB logelb_logLog format for Amazon Elastic Load Balancers
engine logengine_logThe log format for the engine.log files from RHEV/oVirt
env_logger formatenv_logger_logFormat file for Rust’s env_logger crate
Common Error Logerror_logThe default web error log format for servers like Apache.
ESXi Syslogesx_syslog_logFormat specific to the ESXi syslog
Fsck_hfs Logfsck_hfs_logLog for the fsck_hfs tool on Mac OS X.
GitHub Events Loggithub_events_logFormat for the public GitHub timeline from gharchive.org
Glogglog_logThe google glog format.
HAProxy HTTP Log Formathaproxy_logThe HAProxy log format
Java log formatjava_logLog format used by log4j and output by most java programs
journalctl JSON log formatjournald_json_logLogger format as created by systemd journalctl -o json
Katello log formatkatello_logLog format used by katello and foreman as used in Satellite 6.
lnav debug loglnav_debug_logLog format for lnav’s own debug log
Nextcloud server logsnextcloudNextcloud JSON server logs audit.log, flow.log, and nextcloud.log
Nextflow log formatnextflow_logFormat file for nextflow.io logs
OpenAM Logopenam_logThe OpenAM identity provider.
OpenAM Debug Logopenamdb_logDebug logs for the OpenAM identity provider.
OpenStack log formatopenstack_logThe log format for the OpenStack log files
CUPS Page Logpage_logThe CUPS server log of printed pages.
Packet Capturepcap_logInternal format for pcap files
Process Stateprocstate_logPeriodic dumps of process state
Proxifierproxifier_logProxifier proxy client
Ruby on Railsrails_logFormat for ruby on rails
Redisredis_logThe Redis database
S3 Access Logs3_logS3 server access log format
simple_logger formatsimple_rs_logFormat file for Rust’s simple_logger crate
SnapLogic Server Logsnaplogic_logThe SnapLogic server log format.
SSSD log formatsssd_logLog format used by the System Security Services Daemon
Stracestrace_logThe strace output format.
sudosudo_logThe sudo privilege management tool.
Syslogsyslog_logThe system logger format found on most posix systems.
TCF Logtcf_logTarget Communication Framework log
TCSH Historytcsh_historyThe tcsh history file format.
UniFi iptables logunifi_iptables_logThe UniFi gateway iptables logger format (for /var/log/iptables).
UniFi logunifi_logThe UniFi gateway messages logger format (for /var/log/messages).
Uwsgi Loguwsgi_logThe uwsgi log format.
Vdsm Logsvdsm_logVdsm log format
VMKernel Logsvmk_logThe VMKernel’s log format
VMware Logsvmw_logOne of the log formats used in VMware’s ESXi and vCenter software.
VMware vSphere log formatvmw_py_logThe log format for some VMware vSphere services
VMware Go Logvmw_vc_svc_logLog files for go-based logs
VMWare PostgreSQLvpostgres_logFormat for vpostgresql log files with format ‘%m %c %x %d %u %r %p %l’
web robot logweb_robot_log 
RHN server XMLRPC log formatxmlrpc_logGenerated by Satellite’s XMLRPC component
ZooKeeper log formatzookeeper_logLog format for the ZooKeeper coordination service

XSV Formats

In addition to the above formats, the following self-describing formats are supported:

JSON-lines

Logs encoded as JSON-lines can be parsed and pretty-printed in lnav by creating a log format file. The format file is a bit simpler to create since it doesn’t require a regular expression to match plain text. Instead, the format defines the relevant fields and provides a line-format array that specifies how the fields in the JSON object should be displayed.

See the following formats that are built into lnav as examples:

logfmt

There is also basic support for the logfmt convention for formatting log messages. Files that use this format must have the entire line be key/value pairs and the timestamp contained in a field named time or ts. If the file you’re using does not quite follow this formatting, but wraps logfmt data with another recognized format, you can use the logfmt2json(str) SQL function to convert the data into JSON for further analysis.

Defining a New Format

New log formats can be defined by placing JSON configuration files in subdirectories of the /etc/lnav/formats and ~/.lnav/formats/ directories. The directories and files can be named anything you like, but the files must have the ‘.json’ suffix. A sample file containing the builtin configuration will be written to this directory when lnav starts up. You can consult that file when writing your own formats or if you need to modify existing ones. Format directories can also contain ‘.sql’ and ‘.lnav’ script files that can be used automate log file analysis.