logging.xml 35 KB

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