Debian Codegraph @

debian/jl.pod

raw
1 =encoding utf8
2
3 =head1 NAME
4
5 B<jl> - pretty-print JSON logs
6
7 =head1 SYNOPSIS
8
9 B<jl> [I<options...>] [I<file>]
10
11 =head1 DESCRIPTION
12
13 B<jl> is a parser and formatter for JSON logs, making machine-readable JSON logs human readable again.
14
15 B<jl> consumes JSON logs from stdin and writes human-readable logs to stdout. To use B<jl>, just pipe your JSON logs through it:
16
17 ./my-app-executable | jl
18 cat app-log.json | jl
19
20 B<jl> can read from a file:
21
22 jl my-app-log.json
23
24 B<jl> itself doesn't support following log files, but since it can consume from a pipe, you can use B<tail>:
25
26 tail -F app-log.json | jl
27
28 You can page B<jl>'s colorised output using B<less> with the B<-R> flag:
29
30 jl my-app-log.json | less -R
31
32 =head1 OPTIONS
33
34 A summary of options is included below.
35
36 =over
37
38 =item B<-color> B<auto>|B<yes>|B<no>
39
40 Set the color mode. The options are "auto", "yes", and "no". "auto" disables color if stdout is not a TTY (default: "auto")
41
42 =item B<-format> B<compact>|B<logfmt>
43
44 Formatter for logs. The options are "compact" and "logfmt" (default: "compact")
45
46 =item B<-truncate>[B<=false>]
47
48 Whether to truncate strings in the compact formatter (default: true)
49
50 =back
51
52 =head1 FORMATTERS
53
54 B<jl> currently supports two formatters, with plans to make the formatters customizable.
55
56 The default is B<-format compact>, which extracts only important fields from the JSON log, like B<message>, B<timestamp>, B<level>, colorises and presents them in a easy to skim way. It drops unrecognised fields from the logs.
57
58 The other option is B<-format logfmt>, which formats the JSON logs in a way that closely resembles logfmt
59 This option emits all fields from each log line.
60
61 Both formatters echo non-JSON log lines as-is.
62
63 =head1 LOG FORMATS
64
65 JSON application logs tend to have some core shared fields, like B<level>, B<timestamp>, and B<message> which B<jl> tries to discover and prioritise for formatting. For now, the following formats work best with B<jl>. For string fields other than B<level>, only the keys matter.
66
67 Other formats can be used after preprocessing with B<jq>.
68
69 =over
70
71 =item * Java-like:
72
73 {
74 "level": "error",
75 "timestamp": "2019-02-02 15:39:45",
76 "logger": "HelloWorldService",
77 "thread": "main",
78 "message": "hello world",
79 "exception": "java.lang.IllegalArgumentException: The world isn't here\n...stacktraces..."
80 }
81
82 =item * Go/Logrus-like:
83
84 {
85 "level": "error",
86 "timestamp": "2019-02-02 15:39:45",
87 "msg": "hello world",
88 "error": "hello error",
89 "stack": "\nhello\n\thello.go\nworld\n\tworld.go"
90 }
91
92 =back
93
94 =head1 COPYRIGHT
95
96 Copyright (C) 2019-2023 Yunchi Luo
97
98 License: MIT/Expat
99
100 This manual page is based on the README document by the author.
101 It was reformatted and adapted by Andrej Shadura L<< <[email protected]> >>
102 for the Debian project, and is distributed under the same license as the
103 original project.
104
105 =head1 SEE ALSO
106
107 L<jq(1)>,
108 L<< https://blog.codeship.com/logfmt-a-log-format-thats-easy-to-read-and-write/ >>