Debian Codegraph @

c/docs/logging.md

raw
1 ## Logging {#logging}
2
3 ### Backward compatible logging control
4
5 Proton has always supported some control over its internal logging using environment variables. The one that has seen
6 the most use is `PN_TRACE_FRM` which when set to '1', 'on' or 'true' turns on logging of protocol frame traces.
7 This is commonly used on a Unix shell command line like so:
8
9 PN_TRACE_FRM=1 ./proton_program
10
11 Setting `PN_TRACE_FRM` is equivalent to using the @ref PN_LEVEL_FRAME log level setting in the proton @ref logger API.
12
13 There are several other (less used) environment variables which are supported:
14
15 * `PN_TRACE_RAW` - This turns on raw protocol frame tracing and is equivalent to @ref PN_LEVEL_RAW.
16 * `PN_TRACE_EVT` - This is useful for tracing events, but has no direct equivalent in the Logger API.
17 * `PN_TRACE_DRV` - This turns on very verbose miscellaneous tracing, again it has no direct equivalent in the Logger API.
18
19 The last two variables are still supported, but their effect may not be to turn on exactly the same logging messages as
20 prior to the introduction of the Logger API.
21
22 ### Logger control introduced with the logger API
23
24 The @ref logger API uses a single environment variable to control the default logging state - `PN_LOG`. This can include
25 a number of strings which correspond to log levels to turn on, these are in descending order of importance (case is not significant):
26
27 * Error
28 * Warning
29 * Info
30 * Debug
31 * Trace
32
33 These strings can also be suffixed with '+' to mean this level and all the ones above. So specifying 'Info+' means turn on 'Error', 'Warning' and 'Info' levels.
34 For example:
35
36 PN_LOG='info+' ./broker
37
38 * Frame
39 * Raw
40
41 These strings are equivalent to the frame and raw frame protocol traces from `PN_TRACE_FRM` and `PN_TRACE_RAW`, they will ignore any '+' appended to them. For example:
42
43 PN_LOG='frame' ./proton_program
44
45 will have the same effect as the first example in this document.
46
47 * All
48
49 This will turn all known logging levels on. This is probably hardly ever useful as it will produce huge amounts of output. Appending '+' will again have no effect as all logging is already turned on!
50
51 Multiple specifiers can be in the string for more logging levels:
52
53 PN_LOG='error frame' ./proton_program
54
55 this would be useful to see the frame trace logged together with any errors.
56
57