logging.xml 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
  4. <!ENTITY mdash "&#x2014;" >
  5. ]>
  6. <!-- Note: Please use the following terminology:
  7. - daemon - one process (e.g. kea-dhcp4)
  8. - component - one piece of code within a daemon (e.g. libdhcp or hooks)
  9. - server - currently equal to daemon, but the difference will be more
  10. prominent once we add client or relay support
  11. - logger - one instance of isc::log::Logger
  12. - structure - an element in config file (e.g. "Dhcp4")
  13. Do not use:
  14. - module => daemon
  15. -->
  16. <chapter id="logging">
  17. <title>Logging</title>
  18. <section>
  19. <title>Logging Configuration</title>
  20. <para>
  21. During its operation Kea may produce many messages. They differ in
  22. severity (some are more important than others) and source (some are
  23. produced by specific components, e.g. hooks). It is useful to understand
  24. which log messages are needed and which are not and configure your
  25. logging appropriately. For example, debug level messages can be safely
  26. ignored in a typical deployment. They are, however, very useful when
  27. debugging a problem.
  28. </para>
  29. <para>
  30. The logging system in Kea is configured through the
  31. <replaceable>Logging</replaceable> structure in your configuration
  32. file. All daemons (e.g. DHCPv4 and DHCPv6 servers) will use the
  33. configuration in the <replaceable>Logging</replaceable> structure to see
  34. what should be logged and to where. This allows for sharing identical
  35. logging configuration between daemons.
  36. </para>
  37. <section>
  38. <title>Loggers</title>
  39. <para>
  40. Within Kea, a message is logged through an entity called a
  41. "logger". Different components log messages through different
  42. loggers, and each logger can be configured independently of
  43. one another. Some components, in particular the DHCP server
  44. processes, may use multiple loggers to log messages pertaining
  45. to different logical functions of the component. For example,
  46. the DHCPv4 server is using one logger for messages
  47. pertaining to packet reception and transmission, another
  48. logger for messages related to lease allocation and so on.
  49. Some of the libraries used by the Kea servers, e.g. libdhcpsrv
  50. or libhooks library, use their own loggers.
  51. </para>
  52. <para>
  53. Users implementing hooks libraries (code attached to the server at
  54. runtime) are responsible for creating the loggers used by those
  55. libraries. Such loggers should have unique names, different
  56. from the logger names used by Kea. In this way the
  57. messages emitted from the hooks library can be distingued from
  58. messages issued by the core Kea code. Unique names also allow
  59. the loggers to be configured independently of loggers used
  60. by Kea. Whenever it makes sense, a hook library can use multiple
  61. loggers to log messages pertaining to different logical parts
  62. of the library.
  63. </para>
  64. <para>
  65. In the <quote>Logging</quote> structure of a configuration file
  66. you can specify the configuration for zero or more loggers
  67. (including loggers used by the proprietary hooks libraries). If
  68. there are no loggers specified, the code will use default values which
  69. cause Kea to log messages on at least INFO severity to standard
  70. output.
  71. <!-- @todo: add reference to section about controlling default
  72. behavior with env. variables, after #3591 is merged. -->
  73. </para>
  74. <para>
  75. The three most important elements of a logger configuration
  76. are the <option>name</option> (the component that is
  77. generating the messages), the <option>severity</option>
  78. (what to log), and the <option>output_options</option>
  79. (where to log).
  80. </para>
  81. <section>
  82. <title>name (string)</title>
  83. <para>
  84. Each logger in the system has a name, the name being that of the
  85. component binary file using it to log messages. For instance, if you
  86. want to configure logging for the DHCPv4 server, you add an entry
  87. for a logger named <quote>kea-dhcp4</quote>. This configuration will
  88. then be used by the loggers in the DHCPv4 server, and all the
  89. libraries used by it (unless a library defines its own logger and
  90. there is specific logger configuration that applies to that logger).
  91. </para>
  92. <para>
  93. When diagnosing the problem with the server's operation, it is often
  94. desired to use the DEBUG logging level to obtain the verbose output
  95. from the server and libraries it uses. However, high verbosity may
  96. be an overkill for the logging system in cases when the server
  97. is processing high volume traffic. To mitigate this problem, Kea
  98. is using multiple loggers, which can be configured independently
  99. and which are responsible for logging messages from different
  100. functional parts of the server. If the user, trying to diagnose the
  101. problem, has a reasonably high confidence that the problem origins
  102. in a specific function of the server, or the problem is related
  103. to the specific type of operation, he may enable high verbosity
  104. only for the relevant logger, thus limiting the debug messages
  105. to the required minimum.
  106. </para>
  107. <para>
  108. The loggers are associated with a particular library or binary
  109. of Kea. However, each library or binary may (and usually does)
  110. include multiple loggers. For example, the DHCPv4 server binary
  111. contains separate loggers for: packet parsing, for dropped packets,
  112. for callouts etc. Each logger "derives" its configuration from the
  113. root logger. In the typical case, the root logger configuration
  114. is the only logging configuration specified in the configuration
  115. file. Creating a specific configuration for the selected logger,
  116. thus overriding the configuration settings specified in the
  117. root logger configuration, requires putting its configuration
  118. aside of the root logger's configuration with some of the
  119. parameters modified.
  120. </para>
  121. <para>
  122. To illustrate this, suppose you are using the DHCPv4 server
  123. with the root logger <quote>kea-dhcp4</quote> logging at the
  124. INFO level. In order to enable DEBUG verbosity for the DHCPv4
  125. packet drops, you must create configuration entry for the
  126. logger called <quote>kea-dhcp4.bad-packets</quote> and specify
  127. severity DEBUG for this logger. All other configuration
  128. parameters may be omited for this logger if the logger should
  129. use the default values specified in the root logger's
  130. configuration.
  131. </para>
  132. <!-- we don't support asterisk anymore.
  133. <para>
  134. One special case is that of a component name of <quote>*</quote>
  135. (asterisks), which is interpreted as <emphasis>any</emphasis>
  136. component. You can set global logging options by using this,
  137. including setting the logging configuration for a library
  138. that is used by multiple daemons (e.g. <quote>*.config</quote>
  139. specifies the configuration library code in whatever
  140. daemon is using it).
  141. </para> -->
  142. <para>
  143. If there are multiple logger specifications in the configuration
  144. that might match a particular logger, the specification with the
  145. more specific logger name takes precedence. For example, if there
  146. are entries for both <quote>kea-dhcp4</quote> and
  147. <quote>kea-dhcp4.dhcpsrv</quote>, the DHCPv4 server &mdash; and all
  148. libraries it uses that are not dhcpsrv &mdash; will log messages
  149. according to the configuration in the first entry
  150. (<quote>kea-dhcp4</quote>).
  151. </para>
  152. <para>
  153. Currently defined loggers are:
  154. </para>
  155. <itemizedlist>
  156. <listitem>
  157. <simpara><command>kea-dhcp4</command> - this is the root logger for
  158. the DHCPv4 server. All components used by the DHCPv4 server inherit
  159. the settings from this logger if there is no specialized logger
  160. provided.</simpara>
  161. </listitem>
  162. <listitem>
  163. <simpara><command>kea-dhcp4.alloc-engine</command> - this is the
  164. logger used by the lease allocation engine, which is responsible
  165. for managing leases in the lease database, i.e. create, modify
  166. and remove DHCPv4 leases as a result of processing messages from
  167. the clients.</simpara>
  168. </listitem>
  169. <listitem>
  170. <simpara><command>kea-dhcp4.bad-packets</command> - this is the
  171. logger used by the DHCPv4 server deamon for logging inbound client
  172. packets that were dropped or to which the server responded with a
  173. DHCPNAK. The allows adminstrators to configure a separate log
  174. output that contains only packet drop and reject entries.</simpara>
  175. </listitem>
  176. <listitem>
  177. <simpara><command>kea-dhcp4.callouts</command> - this logger is used
  178. to log messages pertaining to the callouts registration and execution
  179. for the particular hook point.
  180. </simpara>
  181. </listitem>
  182. <listitem>
  183. <simpara><command>kea-dhcp4.commands</command> - this logger is used
  184. to log messages relating to the handling of commands received by the
  185. the DHCPv4 server over the command channel.
  186. </simpara>
  187. </listitem>
  188. <listitem>
  189. <simpara><command>kea-dhcp4.ddns</command> - this logger is used by
  190. the DHCPv4 server to log messages related to the Client FQDN and
  191. Hostname option processing. It also includes log messages
  192. related to the relevant DNS updates.</simpara>
  193. </listitem>
  194. <listitem>
  195. <simpara><command>kea-dhcp4.dhcp4</command> - this is the logger
  196. by the DHCPv4 server deamon to log basic operations.</simpara>
  197. </listitem>
  198. <listitem>
  199. <simpara><command>kea-dhcp4.dhcpsrv</command> - this is a base
  200. logger for the libdhcpsrv library.</simpara>
  201. </listitem>
  202. <listitem>
  203. <simpara><command>kea-dhcp4.hooks</command> - this logger is used
  204. to log messages related to management of hooks libraries, e.g.
  205. registration and deregistration of the libraries, and to the
  206. initialization of the callouts execution for various hook points
  207. within the DHCPv4 server.</simpara>
  208. </listitem>
  209. <listitem>
  210. <simpara><command>kea-dhcp4.hosts</command> - this logger is used
  211. within the libdhcpsrv and it logs messages related to the management
  212. of the DHCPv4 host reservations, i.e. retrieval of the resevations
  213. and adding new reservations.</simpara>
  214. </listitem>
  215. <listitem>
  216. <simpara><command>kea-dhcp4.leases</command> - this logger is used
  217. by the DHCPv4 server to log messages related to the lease allocation.
  218. The messages include detailed information about the allocated or
  219. offered leases, errors during the lease allocation etc.
  220. </simpara>
  221. </listitem>
  222. <listitem>
  223. <simpara><command>kea-dhcp4.options</command> - this logger is
  224. used by the DHCPv4 server to log messages related to processing
  225. of the options in the DHCPv4 messages, i.e. parsing options,
  226. encoding options into on-wire format and packet classification
  227. using options contained in the received packets.</simpara>
  228. </listitem>
  229. <listitem>
  230. <simpara><command>kea-dhcp4.packets</command> - this logger
  231. is mostly used to log messages related to transmission of the DHCPv4
  232. packets, i.e. packet reception and sending a response. Such messages
  233. include the information about the source and destination IP addresses
  234. and interfaces used to transmit packets. This logger is also used
  235. to log messages related to subnet selection, as this selection is
  236. usually based on the IP addresses and/or interface names, which can
  237. be retrieved from the received packet, even before the DHCPv4 message
  238. carried in the packet is parsed.
  239. </simpara>
  240. </listitem>
  241. <listitem>
  242. <simpara><command>kea-dhcp6</command> - this is the root logger for
  243. the DHCPv6 server. All components used by the DHCPv6 server inherit
  244. the settings from this logger if there is no specialized logger
  245. provided.</simpara>
  246. </listitem>
  247. <listitem>
  248. <simpara><command>kea-dhcp6.alloc-engine</command> - this is the
  249. logger used by the lease allocation engine, which is responsible
  250. for managing leases in the lease database, i.e. create, modify
  251. and remove DHCPv6 leases as a result of processing messages from
  252. the clients.</simpara>
  253. </listitem>
  254. <listitem>
  255. <simpara><command>kea-dhcp6.bad-packets</command> - this is the
  256. logger used by the DHCPv6 server deamon for logging inbound client
  257. packets that were dropped.</simpara>
  258. </listitem>
  259. <listitem>
  260. <simpara><command>kea-dhcp6.callouts</command> - this logger is used
  261. to log messages pertaining to the callouts registration and execution
  262. for the particular hook point.
  263. </simpara>
  264. </listitem>
  265. <listitem>
  266. <simpara><command>kea-dhcp6.commands</command> - this logger is used
  267. to log messages relating to the handling of commands received by the
  268. the DHCPv6 server over the command channel.
  269. </simpara>
  270. </listitem>
  271. <listitem>
  272. <simpara><command>kea-dhcp6.ddns</command> - this logger is used by
  273. the DHCPv6 server to log messages related to the Client FQDN option
  274. processing. It also includes log messages related to the relevant
  275. DNS updates.</simpara>
  276. </listitem>
  277. <listitem>
  278. <simpara><command>kea-dhcp6.dhcp6</command> - this is the logger
  279. used DHCPv6 server deamon to log basic operations.</simpara>
  280. </listitem>
  281. <listitem>
  282. <simpara><command>kea-dhcp6.dhcpsrv</command> - this is a base
  283. logger for the libdhcpsrv library.</simpara>
  284. </listitem>
  285. <listitem>
  286. <simpara><command>kea-dhcp6.hooks</command> - this logger is used
  287. to log messages related to management of hooks libraries, e.g.
  288. registration and deregistration of the libraries, and to the
  289. initialization of the callouts execution for various hook points
  290. within the DHCPv6 server.</simpara>
  291. </listitem>
  292. <listitem>
  293. <simpara><command>kea-dhcp6.hosts</command> - this logger is used
  294. within the libdhcpsrv and it logs messages related to the management
  295. of the DHCPv6 host reservations, i.e. retrieval of the resevations
  296. and adding new reservations.</simpara>
  297. </listitem>
  298. <listitem>
  299. <simpara><command>kea-dhcp6.leases</command> - this logger is used
  300. by the DHCPv6 server to log messages related to the lease allocation.
  301. The messages include detailed information about the allocated or
  302. offered leases, errors during the lease allocation etc.
  303. </simpara>
  304. </listitem>
  305. <listitem>
  306. <simpara><command>kea-dhcp6.options</command> - this logger is
  307. used by the DHCPv6 server to log messages related to processing
  308. of the options in the DHCPv6 messages, i.e. parsing options,
  309. encoding options into on-wire format and packet classification
  310. using options contained in the received packets.</simpara>
  311. </listitem>
  312. <listitem>
  313. <simpara><command>kea-dhcp6.packets</command> - this logger
  314. is mostly used to log messages related to transmission of the DHCPv6
  315. packets, i.e. packet reception and sending a response. Such messages
  316. include the information about the source and destination IP addresses
  317. and interfaces used to transmit packets. This logger is also used
  318. to log messages related to subnet selection, as this selection is
  319. usually based on the IP addresses and/or interface names, which can
  320. be retrieved from the received packet, even before the DHCPv6 message
  321. carried in the packet is parsed.
  322. </simpara>
  323. </listitem>
  324. <listitem>
  325. <simpara><command>kea-dhcp-ddns</command> - this is the root logger for
  326. the kea-dhcp-ddns deamon. All components used by this deamon inherit
  327. the settings from this logger if there is no specialized logger
  328. provided.</simpara>
  329. </listitem>
  330. <listitem>
  331. <simpara><command>kea-dhcp-ddns.dhcpddns</command> - this is the logger
  332. used by the kea-dhcp-ddns deamon for logging configuration and global
  333. event information. This logger does not specify logging settings
  334. for libraries used by the deamon.</simpara>
  335. </listitem>
  336. <listitem>
  337. <simpara><command>kea-dhcp-ddns.dhcp-to-d2</command> - this is the logger
  338. used by the kea-dhcp-ddns deamon for logging information about events
  339. dealing with receving messages from the DHCP servers and adding them
  340. to the queue for processing.</simpara>
  341. </listitem>
  342. <listitem>
  343. <simpara><command>kea-dhcp-ddns.d2-to-dns</command> - this is the logger
  344. used by the kea-dhcp-ddns deamon for logging information about events
  345. dealing with sending and receiving messages with the DNS servers.
  346. </simpara>
  347. </listitem>
  348. </itemizedlist>
  349. <para>
  350. Note that user-defined hook libraries should not use any of those
  351. loggers, and should define new loggers with names that correspond to
  352. the libraries using them. Suppose that the user created the library called
  353. <quote>libpacket-capture</quote> to dump packets received and
  354. transmitted by the server to the file. The appropriate name for the
  355. logger could be <command>kea-dhcp4.packet-capture</command>. Note
  356. that the hook library implementor only specifies the second part
  357. of this name, i.e. <quote>packet-capture</quote>. The first part is
  358. a root logger name and is prepended by the Kea logging system.
  359. It is also important to note that since this new logger is a child
  360. of a root logger, it inherits the configuration from the root logger,
  361. unless there is a separate configuration entry for the child logger
  362. which overrides the default configuration.
  363. </para>
  364. <para>
  365. The list of loggers above excludes any loggers implemented in hooks
  366. libraries. Please consult the documentation of the specific hooks
  367. libraries for the names of loggers they define.
  368. </para>
  369. <para>Additional loggers may be defined in the future. The easiest
  370. way to find out the logger name is to configure all logging to go
  371. to a single destination and look for specific logger names. See
  372. <xref linkend="logging-message-format"/> for details.</para>
  373. </section>
  374. <section>
  375. <title>severity (string)</title>
  376. <para>
  377. This specifies the category of messages logged.
  378. Each message is logged with an associated severity which
  379. may be one of the following (in descending order of
  380. severity):
  381. </para>
  382. <itemizedlist>
  383. <listitem>
  384. <simpara> FATAL </simpara>
  385. </listitem>
  386. <listitem>
  387. <simpara> ERROR </simpara>
  388. </listitem>
  389. <listitem>
  390. <simpara> WARN </simpara>
  391. </listitem>
  392. <listitem>
  393. <simpara> INFO </simpara>
  394. </listitem>
  395. <listitem>
  396. <simpara> DEBUG </simpara>
  397. </listitem>
  398. </itemizedlist>
  399. <para>
  400. When the severity of a logger is set to one of these
  401. values, it will only log messages of that severity, and
  402. the severities above it. The severity may also be set to
  403. NONE, in which case all messages from that logger are
  404. inhibited.
  405. <!-- TODO: worded wrong? If I set to INFO, why would it show DEBUG which is literally below in that list? -->
  406. </para>
  407. </section>
  408. <section>
  409. <title>output_options (list)</title>
  410. <para>
  411. Each logger can have zero or more
  412. <option>output_options</option>. These specify where log
  413. messages are sent. These are explained in detail below.
  414. </para>
  415. <para>
  416. The other options for a logger are:
  417. </para>
  418. </section>
  419. <section>
  420. <title>debuglevel (integer)</title>
  421. <para>
  422. When a logger's severity is set to DEBUG, this value
  423. specifies what debug messages should be printed. It ranges
  424. from 0 (least verbose) to 99 (most verbose).
  425. </para>
  426. <!-- TODO: complete this sentence:
  427. The general classification of debug message types is
  428. TODO; there's a ticket to determine these levels, see #1074
  429. -->
  430. <para>
  431. If severity for the logger is not DEBUG, this value is ignored.
  432. </para>
  433. </section>
  434. </section>
  435. <section>
  436. <title>Output Options</title>
  437. <para>
  438. The main settings for an output option are the
  439. <option>destination</option> and a value called
  440. <option>output</option>, the meaning of which depends on
  441. the destination that is set.
  442. </para>
  443. <section>
  444. <title>destination (string)</title>
  445. <para>
  446. The destination is the type of output. It can be one of:
  447. </para>
  448. <itemizedlist>
  449. <listitem>
  450. <simpara> console </simpara>
  451. </listitem>
  452. <listitem>
  453. <simpara> file </simpara>
  454. </listitem>
  455. <listitem>
  456. <simpara> syslog </simpara>
  457. </listitem>
  458. </itemizedlist>
  459. </section>
  460. <section>
  461. <title>output (string)</title>
  462. <para>
  463. This value determines the type of output. There are several
  464. special values allowed here: <command>stdout</command> (messages
  465. are printed on standard output), <command>stderr</command>
  466. (messages are printed on stderr), <command>syslog</command> (messages
  467. are logged to syslog using default name, <command>syslog:name</command>
  468. (messages are logged to syslog using specified name). Any other
  469. value is interpreted as a filename that the logs should be written to.
  470. </para>
  471. <para>
  472. The other options for <option>output_options</option> are:
  473. </para>
  474. <section>
  475. <title>flush (true of false)</title>
  476. <para>
  477. Flush buffers after each log message. Doing this will
  478. reduce performance but will ensure that if the program
  479. terminates abnormally, all messages up to the point of
  480. termination are output. Default is true.
  481. </para>
  482. </section>
  483. <section>
  484. <title>maxsize (integer)</title>
  485. <para>
  486. Only relevant when destination is file, this is maximum
  487. file size of output files in bytes. When the maximum
  488. size is reached, the file is renamed and a new file opened.
  489. (For example, a ".1" is appended to the name &mdash;
  490. if a ".1" file exists, it is renamed ".2",
  491. etc.)
  492. </para>
  493. <para>
  494. If this is 0, no maximum file size is used.
  495. </para>
  496. <note>
  497. <simpara>
  498. Due to a limitation of the underlying logging library
  499. (log4cplus), rolling over the log files (from ".1" to
  500. ".2", etc) may show odd results: There can be
  501. multiple small files at the timing of roll over. This
  502. can happen when multiple processes try to roll
  503. over the files simultaneously.
  504. Version 1.1.0 of log4cplus solved this problem, so if
  505. this or higher version of log4cplus is used to build
  506. Kea, it shouldn't happen. Even for older versions
  507. it is normally expected to happen rarely unless the log
  508. messages are produced very frequently by multiple
  509. different processes.
  510. </simpara>
  511. </note>
  512. </section>
  513. <section>
  514. <title>maxver (integer)</title>
  515. <para>
  516. Maximum number of old log files to keep around when
  517. rolling the output file. Only relevant when
  518. <option>output</option> is <quote>file</quote>.
  519. </para>
  520. </section>
  521. </section>
  522. </section>
  523. <section>
  524. <title>Example Logger Configurations</title>
  525. <para>
  526. In this example we want to set the global logging to
  527. write to the console using standard output.
  528. </para>
  529. <screen><userinput>
  530. "Logging": {
  531. "loggers": [
  532. {
  533. "name": "kea-dhcp4",
  534. "output_options": [
  535. {
  536. "output": "stdout"
  537. }
  538. ],
  539. "severity": "WARN"
  540. }
  541. ]
  542. }
  543. </userinput>
  544. </screen>
  545. <para>In this second example, we want to store debug log messages
  546. in a file that is at most 2MB and keep up to 8 copies of old logfiles.
  547. Once the logfile grows to 2MB, it will be renamed and a new file
  548. file be created.</para>
  549. <screen><userinput>
  550. "Logging": {
  551. "loggers": [
  552. {
  553. "name": "kea-dhcp6",
  554. "output_options": [
  555. {
  556. "output": "/var/log/kea-debug.log",
  557. "maxver": 8,
  558. "maxsize": 204800,
  559. "flush": true
  560. }
  561. ],
  562. "severity": "DEBUG",
  563. "debuglevel": 99
  564. }
  565. ]
  566. }</userinput></screen>
  567. </section>
  568. </section>
  569. <section id="logging-message-format">
  570. <title>Logging Message Format</title>
  571. <para>
  572. Each message written to the configured logging
  573. destinations comprises a number of components that identify
  574. the origin of the message and, if the message indicates
  575. a problem, information about the problem that may be
  576. useful in fixing it.
  577. </para>
  578. <para>
  579. Consider the message below logged to a file:
  580. <screen>2014-04-11 12:58:01.005 INFO [kea-dhcp4.dhcpsrv/27456]
  581. DHCPSRV_MEMFILE_DB opening memory file lease database: type=memfile universe=4</screen>
  582. </para>
  583. <para>
  584. Note: the layout of messages written to the system logging
  585. file (syslog) may be slightly different. This message has
  586. been split across two lines here for display reasons; in the
  587. logging file, it will appear on one line.
  588. </para>
  589. <para>
  590. The log message comprises a number of components:
  591. <variablelist>
  592. <varlistentry>
  593. <term>2014-04-11 12:58:01.005</term>
  594. <!-- TODO: timestamp repeated even if using syslog? -->
  595. <listitem><para>
  596. The date and time at which the message was generated.
  597. </para></listitem>
  598. </varlistentry>
  599. <varlistentry>
  600. <term>INFO</term>
  601. <listitem><para>
  602. The severity of the message.
  603. </para></listitem>
  604. </varlistentry>
  605. <varlistentry>
  606. <term>[kea-dhcp4.dhcpsrv/27456]</term>
  607. <listitem><para>
  608. The source of the message. This comprises two elements:
  609. the Kea process generating the message (in this
  610. case, <command>kea-dhcp4</command>) and the component
  611. within the program from which the message originated
  612. (which is the name of the common library used by DHCP server
  613. implementations). The number after the slash is a process id
  614. (pid).
  615. </para></listitem>
  616. </varlistentry>
  617. <varlistentry>
  618. <term>DHCPSRV_MEMFILE_DB</term>
  619. <listitem><para>
  620. The message identification. Every message in Kea
  621. has a unique identification, which can be used as an
  622. index into the <ulink
  623. url="kea-messages.html"><citetitle>Kea Messages
  624. Manual</citetitle></ulink> (<ulink
  625. url="http://kea.isc.org/docs/kea-messages.html"
  626. />) from which more information can be obtained.
  627. </para></listitem>
  628. </varlistentry>
  629. <varlistentry>
  630. <term>opening memory file lease database: type=memfile universe=4</term>
  631. <listitem><para>
  632. A brief description.
  633. Within this text, information relating to the condition
  634. that caused the message to be logged will be included.
  635. In this example, the information is logged that the in-memory
  636. lease database backend will be used to store DHCP leases.
  637. </para></listitem>
  638. </varlistentry>
  639. </variablelist>
  640. </para>
  641. </section>
  642. <section>
  643. <title>Logging During Kea Startup</title>
  644. <para>
  645. The logging configuration is specified in the configuration file.
  646. However, when Kea starts, the file is not read until some way into the
  647. initialization process. Prior to that, the logging settings are
  648. set to default values, although it is possible to modify some
  649. aspects of the settings by means of environment variables. Note
  650. that in the absence of any logging configuration in the configuration
  651. file, the settings of (possibly modified) default configuration will
  652. persist while the program is running.
  653. </para>
  654. <para>
  655. The following environment variables can be used to control the
  656. behavio of logging during startup:
  657. </para>
  658. <variablelist>
  659. <varlistentry>
  660. <term>KEA_LOCKFILE_DIR</term>
  661. <listitem><para>
  662. Specifies a directory where the logging system should create its
  663. lock file. If not specified, it is
  664. <replaceable>prefix</replaceable>/var/run/kea, where
  665. <replaceable>prefix</replaceable> defaults to /usr/local.
  666. This variable must not end
  667. with a slash. There is one special value: "none", which
  668. instructs Kea to not create lock file at all. This may cause
  669. issues if several processes log to the same file.
  670. </para></listitem>
  671. </varlistentry>
  672. <varlistentry>
  673. <term>KEA_LOGGER_DESTINATION</term>
  674. <listitem><para>
  675. Specifies logging output. There are several special values.
  676. <variablelist>
  677. <varlistentry>
  678. <term>stdout</term>
  679. <listitem><para>
  680. Log to standard output.
  681. </para></listitem>
  682. </varlistentry>
  683. <varlistentry>
  684. <term>stderr</term>
  685. <listitem><para>
  686. Log to standard error.
  687. </para></listitem>
  688. </varlistentry>
  689. <varlistentry>
  690. <term>syslog<optional>:<replaceable>fac</replaceable></optional></term>
  691. <listitem><para>
  692. Log via syslog. The optional
  693. <replaceable>fac</replaceable> (which is
  694. separated from the word "syslog" by a colon)
  695. specifies the
  696. facility to be used for the log messages. Unless
  697. specified, messages will be logged using the
  698. facility "local0".
  699. </para></listitem>
  700. </varlistentry>
  701. </variablelist>
  702. Any other value is treated as a name
  703. of the output file. If not specified otherwise, Kea will log to
  704. standard output.
  705. </para></listitem>
  706. </varlistentry>
  707. </variablelist>
  708. </section>
  709. </chapter>