Configuration
The configuration for lnav is stored in the following JSON files in
~/.lnav
:
config.json
– Contains local customizations that were done using the:config
command.configs/default/*.json
– The default configuration files that are built into lnav are written to this directory with.sample
appended. Removing the.sample
extension and editing the file will allow you to do basic customizations.configs/installed/*.json
– Contains configuration files installed using the-i
flag (e.g.$ lnav -i /path/to/config.json
).configs/*/*.json
– Other directories that contain*.json
files will be loaded on startup. This structure is convenient for installing lnav configurations, like from a git repository.
A valid lnav configuration file must contain an object with the
$schema
property, like so:
{
"$schema": "https://lnav.org/schemas/config-v1.schema.json"
}
Note
Log format definitions are stored separately in the ~/.lnav/formats
directly. See the Log Formats chapter for more
information.
Options
The following configuration options can be used to customize the lnav UI to
your liking. The options can be changed using the :config
command.
/ui/keymap
The name of the keymap to use. |
|
type |
string |
/ui/theme
The name of the theme to use. |
|
type |
string |
/ui/clock-format
The format for the clock displayed in the top-left corner using strftime(3) conversions |
|
type |
string |
examples |
%a %b %d %H:%M:%S %Z |
/ui/dim-text
Reduce the brightness of text (useful for xterms). This setting can be useful when running in an xterm where the white color is very bright. |
|
type |
boolean |
/ui/default-colors
Use default terminal background and foreground colors instead of black and white for all text coloring. This setting can be useful when transparent background or alternate color theme terminal is used. |
|
type |
boolean |
Theme Definitions
User Interface themes are defined in a JSON configuration file. A theme is made up of the style definitions for different types of text in the UI. A definition can include the foreground/background colors and the bold/underline attributes. The style definitions are broken up into multiple categories for the sake of organization. To make it easier to write a definition, a theme can define variables that can be referenced as color values.
Variables
The vars
object in a theme definition contains the mapping of variable
names to color values. These variables can be referenced in style definitions
by prefixing them with a dollar-sign (e.g. $black
). The following
variables can also be defined to control the values of the ANSI colors that
are log messages or plain text:
Variable Name |
ANSI Escape |
---|---|
black |
ESC[30m |
red |
ESC[31m |
green |
ESC[32m |
yellow |
ESC[33m |
blue |
ESC[34m |
magenta |
ESC[35m |
cyan |
ESC[36m |
white |
ESC[37m |
Specifying Colors
Colors can be specified using hexadecimal notation by starting with a hash
(e.g. #aabbcc
) or using a color name as found at
http://jonasjacek.github.io/colors/. If colors are not specified for a style,
the values from the styles/text
definition.
Note
When specifying colors in hexadecimal notation, you do not need to have an exact match in the XTerm 256 color palette. A best approximation will be picked based on the CIEDE2000 color difference algorithm.
Example
The following example sets the black/background color for text to a dark grey
using a variable and sets the foreground to an off-white. This theme is
incomplete, but it works enough to give you an idea of how a theme is defined.
You can copy the code block, save it to a file in
~/.lnav/configs/installed/
and then activate it by executing
:config /ui/theme example
in lnav. For a more complete theme
definition, see one of the definitions built into lnav, like
monocai.
{ "$schema": "https://lnav.org/schemas/config-v1.schema.json", "ui": { "theme-defs": { "example1": { "vars": { "black": "#2d2a2e" }, "styles": { "text": { "color": "#f6f6f6", "background-color": "$black" } } } } } }
Reference
/ui/theme-defs/<theme_name>/vars
Variables definitions that are used in this theme. |
||
type |
object |
|
patternProperties |
||
|
/ui/theme-defs/<theme_name>/vars/<var_name> |
|
A theme variable definition |
||
type |
string |
|
additionalProperties |
False |
/ui/theme-defs/<theme_name>/styles
Styles for log messages. |
|
type |
object |
properties |
|
|
/ui/theme-defs/<theme_name>/styles/identifier |
Styling for identifiers in logs |
|
|
/ui/theme-defs/<theme_name>/styles/text |
Styling for plain text |
|
|
/ui/theme-defs/<theme_name>/styles/alt-text |
Styling for plain text when alternating |
|
|
/ui/theme-defs/<theme_name>/styles/error |
Styling for error messages |
|
|
/ui/theme-defs/<theme_name>/styles/ok |
Styling for success messages |
|
|
/ui/theme-defs/<theme_name>/styles/info |
Styling for informational messages |
|
|
/ui/theme-defs/<theme_name>/styles/warning |
Styling for warning messages |
|
|
/ui/theme-defs/<theme_name>/styles/hidden |
Styling for hidden fields in logs |
|
|
/ui/theme-defs/<theme_name>/styles/cursor-line |
Styling for the cursor line in the main view |
|
|
/ui/theme-defs/<theme_name>/styles/adjusted-time |
Styling for timestamps that have been adjusted |
|
|
/ui/theme-defs/<theme_name>/styles/skewed-time |
Styling for timestamps that are different from the received time |
|
|
/ui/theme-defs/<theme_name>/styles/offset-time |
Styling for hidden fields |
|
|
/ui/theme-defs/<theme_name>/styles/invalid-msg |
Styling for invalid log messages |
|
|
/ui/theme-defs/<theme_name>/styles/popup |
Styling for popup windows |
|
|
/ui/theme-defs/<theme_name>/styles/focused |
Styling for a focused row in a list view |
|
|
/ui/theme-defs/<theme_name>/styles/disabled-focused |
Styling for a disabled focused row in a list view |
|
|
/ui/theme-defs/<theme_name>/styles/scrollbar |
Styling for scrollbars |
|
|
/ui/theme-defs/<theme_name>/styles/h1 |
Styling for top-level headers |
|
|
/ui/theme-defs/<theme_name>/styles/h2 |
Styling for 2nd-level headers |
|
|
/ui/theme-defs/<theme_name>/styles/h3 |
Styling for 3rd-level headers |
|
|
/ui/theme-defs/<theme_name>/styles/h4 |
Styling for 4th-level headers |
|
|
/ui/theme-defs/<theme_name>/styles/h5 |
Styling for 5th-level headers |
|
|
/ui/theme-defs/<theme_name>/styles/h6 |
Styling for 6th-level headers |
|
|
/ui/theme-defs/<theme_name>/styles/hr |
Styling for horizontal rules |
|
|
/ui/theme-defs/<theme_name>/styles/hyperlink |
Styling for hyperlinks |
|
|
/ui/theme-defs/<theme_name>/styles/list-glyph |
Styling for glyphs that prefix a list item |
|
|
/ui/theme-defs/<theme_name>/styles/breadcrumb |
Styling for the separator between breadcrumbs |
|
|
/ui/theme-defs/<theme_name>/styles/table-border |
Styling for table borders |
|
|
/ui/theme-defs/<theme_name>/styles/table-header |
Styling for table headers |
|
|
/ui/theme-defs/<theme_name>/styles/quote-border |
Styling for quoted-block borders |
|
|
/ui/theme-defs/<theme_name>/styles/quoted-text |
Styling for quoted text blocks |
|
|
/ui/theme-defs/<theme_name>/styles/footnote-border |
Styling for footnote borders |
|
|
/ui/theme-defs/<theme_name>/styles/footnote-text |
Styling for footnote text |
|
|
/ui/theme-defs/<theme_name>/styles/snippet-border |
Styling for snippet borders |
|
additionalProperties |
False |
/ui/theme-defs/<theme_name>/syntax-styles
Styles for syntax highlighting in text files. |
|
type |
object |
properties |
|
|
/ui/theme-defs/<theme_name>/syntax-styles/quoted-code |
Styling for quoted code blocks |
|
|
/ui/theme-defs/<theme_name>/syntax-styles/code-border |
Styling for quoted-code borders |
|
|
/ui/theme-defs/<theme_name>/syntax-styles/keyword |
Styling for keywords in source files |
|
|
/ui/theme-defs/<theme_name>/syntax-styles/string |
Styling for single/double-quoted strings in text |
|
|
/ui/theme-defs/<theme_name>/syntax-styles/comment |
Styling for comments in source files |
|
|
/ui/theme-defs/<theme_name>/syntax-styles/doc-directive |
Styling for documentation directives in source files |
|
|
/ui/theme-defs/<theme_name>/syntax-styles/variable |
Styling for variables in text |
|
|
/ui/theme-defs/<theme_name>/syntax-styles/symbol |
Styling for symbols in source files |
|
|
/ui/theme-defs/<theme_name>/syntax-styles/number |
Styling for numbers in source files |
|
|
/ui/theme-defs/<theme_name>/syntax-styles/re-special |
Styling for special characters in regular expressions |
|
|
/ui/theme-defs/<theme_name>/syntax-styles/re-repeat |
Styling for repeats in regular expressions |
|
|
/ui/theme-defs/<theme_name>/syntax-styles/diff-delete |
Styling for deleted lines in diffs |
|
|
/ui/theme-defs/<theme_name>/syntax-styles/diff-add |
Styling for added lines in diffs |
|
|
/ui/theme-defs/<theme_name>/syntax-styles/diff-section |
Styling for diffs |
|
|
/ui/theme-defs/<theme_name>/syntax-styles/spectrogram-low |
Styling for the lower threshold values in the spectrogram view |
|
|
/ui/theme-defs/<theme_name>/syntax-styles/spectrogram-medium |
Styling for the medium threshold values in the spectrogram view |
|
|
/ui/theme-defs/<theme_name>/syntax-styles/spectrogram-high |
Styling for the high threshold values in the spectrogram view |
|
|
/ui/theme-defs/<theme_name>/syntax-styles/file |
Styling for file names in source files |
|
additionalProperties |
False |
/ui/theme-defs/<theme_name>/status-styles
Styles for the user-interface components. |
|
type |
object |
properties |
|
|
/ui/theme-defs/<theme_name>/status-styles/text |
Styling for status bars |
|
|
/ui/theme-defs/<theme_name>/status-styles/warn |
Styling for warnings in status bars |
|
|
/ui/theme-defs/<theme_name>/status-styles/alert |
Styling for alerts in status bars |
|
|
/ui/theme-defs/<theme_name>/status-styles/active |
Styling for activity in status bars |
|
|
/ui/theme-defs/<theme_name>/status-styles/inactive-alert |
Styling for inactive alert status bars |
|
|
/ui/theme-defs/<theme_name>/status-styles/inactive |
Styling for inactive status bars |
|
|
/ui/theme-defs/<theme_name>/status-styles/title-hotkey |
Styling for hotkey highlights in titles |
|
|
/ui/theme-defs/<theme_name>/status-styles/title |
Styling for title sections of status bars |
|
|
/ui/theme-defs/<theme_name>/status-styles/disabled-title |
Styling for title sections of status bars |
|
|
/ui/theme-defs/<theme_name>/status-styles/subtitle |
Styling for subtitle sections of status bars |
|
|
/ui/theme-defs/<theme_name>/status-styles/info |
Styling for informational messages in status bars |
|
|
/ui/theme-defs/<theme_name>/status-styles/hotkey |
Styling for hotkey highlights of status bars |
|
additionalProperties |
False |
/ui/theme-defs/<theme_name>/log-level-styles
Styles for each log message level. |
|
type |
object |
patternProperties |
|
|
/ui/theme-defs/<theme_name>/log-level-styles/<level> |
additionalProperties |
False |
style
type |
object |
|
properties |
||
|
/color |
|
The foreground color value for this style. The value can be the name of an xterm color, the hexadecimal value, or a theme variable reference. |
||
type |
string |
|
examples |
#fff |
|
Green |
||
$black |
||
|
/background-color |
|
The background color value for this style. The value can be the name of an xterm color, the hexadecimal value, or a theme variable reference. |
||
type |
string |
|
examples |
#2d2a2e |
|
Green |
||
|
/underline |
|
Indicates that the text should be underlined. |
||
type |
boolean |
|
|
/bold |
|
Indicates that the text should be bolded. |
||
type |
boolean |
|
additionalProperties |
False |
Keymap Definitions
Keymaps in lnav map a key sequence to a command to execute. When a key is
pressed, it is converted into a hex-encoded string that is looked up in the
keymap. The command
value associated with the entry in the keymap is
then executed. Note that the “command” can be an lnav
command, a SQL statement/query, or an
lnav script. If an alt-msg
value is included in the entry, the
bottom-right section of the UI will be updated with the help text.
Note
Not all functionality is available via commands or SQL at the moment. Also, some hotkeys are not implemented via keymaps.
Key Sequence Encoding
Key presses are converted into a hex-encoded string that is used to lookup an
entry in the keymap. Each byte of the keypress value is formatted as an
x
followed by the hex-encoding in lowercase. For example, the encoding
for the £ key would be xc2xa3
. To make it easier to discover the
encoding for unassigned keys, lnav will print in the command prompt the
:config
command and
JSON-Pointer for assigning a command
to the key.

Screenshot of the command prompt when an unassigned key is pressed.
Note
Since lnav is a terminal application, it can only receive keypresses that can be represented as characters or escape sequences. For example, it cannot handle the press of a modifier key.
Reference
/ui/keymap-defs/<keymap_name>
The keymap definitions |
|||
type |
object |
||
patternProperties |
|||
|
/ui/keymap-defs/<keymap_name>/<key_seq> |
||
Map of key codes to commands to execute. The field names are the keys to be mapped using as a hexadecimal representation of the UTF-8 encoding. Each byte of the UTF-8 should start with an ‘x’ followed by the hexadecimal representation of the byte. |
|||
type |
object |
||
properties |
|||
|
/ui/keymap-defs/<keymap_name>/<key_seq>/command |
||
The command to execute for the given key sequence. Use a script to execute more complicated operations. |
|||
type |
string |
||
examples |
:goto next hour |
||
pattern |
^[:|;].* |
||
|
/ui/keymap-defs/<keymap_name>/<key_seq>/alt-msg |
||
The help message to display after the key is pressed. |
|||
type |
string |
||
additionalProperties |
False |
||
additionalProperties |
False |
Log Handling
The handling of logs is largely determined by the log file formats, this section covers options that are not specific to a particular format.
Watch Expressions (v0.11.0+)
Watch expressions can be used to fire an event when a log message matches a
condition. You can then install a listener for these events and trigger an
action to be performed. For example, to automate filtering based on
identifiers, a watch expression can match messages that mention the ID and then
a trigger can install a filter for that ID. Creating a watch expression is
done by adding an entry into the /log/watch-expressions
configuration
tree. For example, to create a watch named “dhcpdiscover” that matches
DHCPDISCOVER messages from the dhclient
daemon, you would run the
following:
:config /log/watch-expressions/dhcpdiscover/expr :log_procname = 'dhclient' AND startswith(:log_body, 'DHCPDISCOVER')
The watch expression can refer to column names in the log message by prefixing
them with a colon. The expression is evaluated by passing the log message
fields as bound parameters and not against a table. The easiest way to test
out an expression is with the :mark-expr expr command, since it will behave
similarly. After changing the configuration, you’ll need to restart lnav
for the effect to take place. You can then query the lnav_events
table to see any generated
https://lnav.org/event-log-msg-detected-v1.schema.json
events from the
logs that were loaded:
;SELECT * FROM lnav_events
From there, you can create a SQLite trigger on the lnav_events
table
that will examine the event contents and perform an action. See the
Events (v0.11.0+) section for more information on handling events.
Reference
/log/watch-expressions/<watch_name>
A log message watch expression |
||
type |
object |
|
properties |
||
|
/log/watch-expressions/<watch_name>/expr |
|
The SQL expression to execute for each input line. If expression evaluates to true, a ‘log message detected’ event will be published. |
||
type |
string |
|
|
/log/watch-expressions/<watch_name>/enabled |
|
Indicates whether or not this expression should be evaluated during log processing. |
||
type |
boolean |
|
additionalProperties |
False |
Tuning
The following configuration options can be used to tune the internals of
lnav to your liking. The options can be changed using the :config
command.
/tuning/archive-manager
Settings related to opening archive files |
||
type |
object |
|
properties |
||
|
/tuning/archive-manager/min-free-space |
|
The minimum free space, in bytes, to maintain when unpacking archives |
||
type |
integer |
|
minimum |
0 |
|
|
/tuning/archive-manager/cache-ttl |
|
The time-to-live for unpacked archives, expressed as a duration (e.g. ‘3d’ for three days) |
||
type |
string |
|
examples |
3d |
|
12h |
||
additionalProperties |
False |
/tuning/clipboard
Settings related to the clipboard |
||||
type |
object |
|||
properties |
||||
|
/tuning/clipboard/impls |
|||
Clipboard implementations |
||||
type |
object |
|||
patternProperties |
||||
|
/tuning/clipboard/impls/<clipboard_impl_name> |
|||
Clipboard implementation |
||||
type |
object |
|||
properties |
||||
|
/tuning/clipboard/impls/<clipboard_impl_name>/test |
|||
The command that checks |
||||
type |
string |
|||
examples |
command -v pbcopy |
|||
|
/tuning/clipboard/impls/<clipboard_impl_name>/general |
|||
Commands to work with the general clipboard |
||||
|
/tuning/clipboard/impls/<clipboard_impl_name>/find |
|||
Commands to work with the find clipboard |
||||
additionalProperties |
False |
|||
additionalProperties |
False |
|||
additionalProperties |
False |
clip-commands
Container for the commands used to read from and write to the system clipboard |
||
type |
object |
|
properties |
||
|
/write |
|
The command used to write to the clipboard |
||
type |
string |
|
examples |
pbcopy |
|
|
/read |
|
The command used to read from the clipboard |
||
type |
string |
|
examples |
pbpaste |
|
additionalProperties |
False |
/tuning/file-vtab
Settings related to the lnav_file virtual-table |
||
type |
object |
|
properties |
||
|
/tuning/file-vtab/max-content-size |
|
The maximum allowed file size for the content column |
||
type |
integer |
|
minimum |
0 |
|
additionalProperties |
False |
/tuning/logfile
Settings related to log files |
||
type |
object |
|
properties |
||
|
/tuning/logfile/max-unrecognized-lines |
|
The maximum number of lines in a file to use when detecting the format |
||
type |
integer |
|
minimum |
1 |
|
additionalProperties |
False |
/tuning/remote/ssh
Settings related to the ssh command used to contact remote machines |
|||
type |
object |
||
properties |
|||
|
/tuning/remote/ssh/command |
||
The SSH command to execute |
|||
type |
string |
||
|
/tuning/remote/ssh/transfer-command |
||
Command executed on the remote host when transferring the file |
|||
type |
string |
||
|
/tuning/remote/ssh/start-command |
||
Command executed on the remote host to start the tailer |
|||
type |
string |
||
|
/tuning/remote/ssh/flags |
||
The flags to pass to the SSH command |
|||
type |
string |
||
|
/tuning/remote/ssh/options |
||
The options to pass to the SSH command |
|||
type |
object |
||
patternProperties |
|||
|
/tuning/remote/ssh/options/<option_name> |
||
Set an option to be passed to the SSH command |
|||
type |
string |
||
additionalProperties |
False |
||
|
/tuning/remote/ssh/config |
||
The ssh_config options to pass to SSH with the -o option |
|||
type |
object |
||
patternProperties |
|||
|
/tuning/remote/ssh/config/<config_name> |
||
Set an SSH configuration value |
|||
type |
string |
||
additionalProperties |
False |
||
additionalProperties |
False |