blob: b8fc3b279dbf9cd9f94a79c82745897151a0bd1d [file] [log] [blame]
dmcoomes57e238f2017-09-11 22:52:32 -05001ndn-log
2=======
3
4The ndn-cxx logging facility exposes the internal state of NDN libraries and
5applications so the user can investigate internal interactions, such as interest
6dispatch inside ndn::Face, Data and Interest validation in the security framework,
7sync and recovery Interest processing inside ChronoSync, etc. During runtime, the
8user is able to specify the types of messages he or she would like to receive from
9a set of logging modules pre-configured by library and application developers.
10
11Environment Variable
12--------------------
13
14One way to control ndn-cxx logging facility is through the environment variable
15``NDN_LOG``. Using this variable, one can set the log levels for the available logging
16modules. Logging modules within different libraries and applications usually have
17distinguishing prefixes (``ndn.``, ``sync.``, etc.), which can be specified when
18setting the environment variable. Wildcards can be used to enable logging for all
19modules (just ``*``) or all modules under a selected prefix (e.g., ``ndn.*``).
20
21ndn-cxx logging facility provides a mechanism to manage the type of log messages
22that are written by classifying log messages by severity levels. Listed below
23are the available log levels.
24
25**Log Levels:**
26
27::
28
29 TRACE
30 DEBUG
31 INFO
32 WARN
33 ERROR
34 FATAL
35
36A message's severity level will determine whether the log is written. For instance,
37if an application sets its log severity level to DEBUG, all messages marked with
38DEBUG, or any of those below that level, are written. FATAL level logs are always
39written.
40
41Setting NDN_LOG requires the following syntax with as many prefixes and
42corresponding loglevels as the user desires:
43
44 export NDN_LOG="<prefix1>=<loglevel1>:<prefix2>=<loglevel2>"
45
46**Examples:**
47
48::
49
50 export NDN_LOG="ndn.*=DEBUG"
51 export NDN_LOG="ndn.UnixTransport=INFO"
52 export NDN_LOG="sync.Logic=ERROR"
53 export NDN_LOG="*=DEBUG:ndn.UnixTransport=INFO:sync.Logic=ERROR"
54
55**Note:**
56
57Shorter (general) prefixes should be placed before longer (specific) prefixes.
58Otherwise, the specific prefix's loglevel will be overwritten. For example,
59`export NDN_LOG="ndn.UnixTransport=TRACE:ndn.*=ERROR:*=INFO"` sets all modules
60to INFO; it should be written as
61`export NDN_LOG="*=INFO:ndn.*=ERROR:ndn.UnixTransport=TRACE"` for the desired effect.
62
63**Note:**
64
65Setting the environment variable with sudo requires the application to be run
66in the same command.
67
68::
69
70 Correct:
71
72 sudo env NDN_LOG=logLevel ./ndn-application
73
74 sudo -s
75 export NDN_LOG=logLevel
76 ./ndn-application
77
78 Incorrect:
79
80 sudo export NDN_LOG=logLevel
81 sudo ./ndn-application
82
83 NDN_LOG=logLevel sudo ./ndn-application