logging.xml 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830
  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.eval</command> - this logger is used
  204. to log messages relating to the client classification expression
  205. evaluation code.</simpara>
  206. </listitem>
  207. <listitem>
  208. <simpara><command>kea-dhcp4.hooks</command> - this logger is used
  209. to log messages related to management of hooks libraries, e.g.
  210. registration and deregistration of the libraries, and to the
  211. initialization of the callouts execution for various hook points
  212. within the DHCPv4 server.</simpara>
  213. </listitem>
  214. <listitem>
  215. <simpara><command>kea-dhcp4.hosts</command> - this logger is used
  216. within the libdhcpsrv and it logs messages related to the management
  217. of the DHCPv4 host reservations, i.e. retrieval of the resevations
  218. and adding new reservations.</simpara>
  219. </listitem>
  220. <listitem>
  221. <simpara><command>kea-dhcp4.leases</command> - this logger is used
  222. by the DHCPv4 server to log messages related to the lease allocation.
  223. The messages include detailed information about the allocated or
  224. offered leases, errors during the lease allocation etc.
  225. </simpara>
  226. </listitem>
  227. <listitem>
  228. <simpara><command>kea-dhcp4.options</command> - this logger is
  229. used by the DHCPv4 server to log messages related to processing
  230. of the options in the DHCPv4 messages, i.e. parsing options,
  231. encoding options into on-wire format and packet classification
  232. using options contained in the received packets.</simpara>
  233. </listitem>
  234. <listitem>
  235. <simpara><command>kea-dhcp4.packets</command> - this logger
  236. is mostly used to log messages related to transmission of the DHCPv4
  237. packets, i.e. packet reception and sending a response. Such messages
  238. include the information about the source and destination IP addresses
  239. and interfaces used to transmit packets. This logger is also used
  240. to log messages related to subnet selection, as this selection is
  241. usually based on the IP addresses and/or interface names, which can
  242. be retrieved from the received packet, even before the DHCPv4 message
  243. carried in the packet is parsed.
  244. </simpara>
  245. </listitem>
  246. <listitem>
  247. <simpara><command>kea-dhcp6</command> - this is the root logger for
  248. the DHCPv6 server. All components used by the DHCPv6 server inherit
  249. the settings from this logger if there is no specialized logger
  250. provided.</simpara>
  251. </listitem>
  252. <listitem>
  253. <simpara><command>kea-dhcp6.alloc-engine</command> - this is the
  254. logger used by the lease allocation engine, which is responsible
  255. for managing leases in the lease database, i.e. create, modify
  256. and remove DHCPv6 leases as a result of processing messages from
  257. the clients.</simpara>
  258. </listitem>
  259. <listitem>
  260. <simpara><command>kea-dhcp6.bad-packets</command> - this is the
  261. logger used by the DHCPv6 server deamon for logging inbound client
  262. packets that were dropped.</simpara>
  263. </listitem>
  264. <listitem>
  265. <simpara><command>kea-dhcp6.callouts</command> - this logger is used
  266. to log messages pertaining to the callouts registration and execution
  267. for the particular hook point.
  268. </simpara>
  269. </listitem>
  270. <listitem>
  271. <simpara><command>kea-dhcp6.commands</command> - this logger is used
  272. to log messages relating to the handling of commands received by the
  273. the DHCPv6 server over the command channel.
  274. </simpara>
  275. </listitem>
  276. <listitem>
  277. <simpara><command>kea-dhcp6.ddns</command> - this logger is used by
  278. the DHCPv6 server to log messages related to the Client FQDN option
  279. processing. It also includes log messages related to the relevant
  280. DNS updates.</simpara>
  281. </listitem>
  282. <listitem>
  283. <simpara><command>kea-dhcp6.dhcp6</command> - this is the logger
  284. used DHCPv6 server deamon to log basic operations.</simpara>
  285. </listitem>
  286. <listitem>
  287. <simpara><command>kea-dhcp6.dhcpsrv</command> - this is a base
  288. logger for the libdhcpsrv library.</simpara>
  289. </listitem>
  290. <listitem>
  291. <simpara><command>kea-dhcp6.eval</command> - this logger is used
  292. to log messages relating to the client classification expression
  293. evaluation code.</simpara>
  294. </listitem>
  295. <listitem>
  296. <simpara><command>kea-dhcp6.hooks</command> - this logger is used
  297. to log messages related to management of hooks libraries, e.g.
  298. registration and deregistration of the libraries, and to the
  299. initialization of the callouts execution for various hook points
  300. within the DHCPv6 server.</simpara>
  301. </listitem>
  302. <listitem>
  303. <simpara><command>kea-dhcp6.hosts</command> - this logger is used
  304. within the libdhcpsrv and it logs messages related to the management
  305. of the DHCPv6 host reservations, i.e. retrieval of the resevations
  306. and adding new reservations.</simpara>
  307. </listitem>
  308. <listitem>
  309. <simpara><command>kea-dhcp6.leases</command> - this logger is used
  310. by the DHCPv6 server to log messages related to the lease allocation.
  311. The messages include detailed information about the allocated or
  312. offered leases, errors during the lease allocation etc.
  313. </simpara>
  314. </listitem>
  315. <listitem>
  316. <simpara><command>kea-dhcp6.options</command> - this logger is
  317. used by the DHCPv6 server to log messages related to processing
  318. of the options in the DHCPv6 messages, i.e. parsing options,
  319. encoding options into on-wire format and packet classification
  320. using options contained in the received packets.</simpara>
  321. </listitem>
  322. <listitem>
  323. <simpara><command>kea-dhcp6.packets</command> - this logger
  324. is mostly used to log messages related to transmission of the DHCPv6
  325. packets, i.e. packet reception and sending a response. Such messages
  326. include the information about the source and destination IP addresses
  327. and interfaces used to transmit packets. This logger is also used
  328. to log messages related to subnet selection, as this selection is
  329. usually based on the IP addresses and/or interface names, which can
  330. be retrieved from the received packet, even before the DHCPv6 message
  331. carried in the packet is parsed.
  332. </simpara>
  333. </listitem>
  334. <listitem>
  335. <simpara><command>kea-dhcp-ddns</command> - this is the root logger for
  336. the kea-dhcp-ddns deamon. All components used by this deamon inherit
  337. the settings from this logger if there is no specialized logger
  338. provided.</simpara>
  339. </listitem>
  340. <listitem>
  341. <simpara><command>kea-dhcp-ddns.dhcpddns</command> - this is the logger
  342. used by the kea-dhcp-ddns deamon for logging configuration and global
  343. event information. This logger does not specify logging settings
  344. for libraries used by the deamon.</simpara>
  345. </listitem>
  346. <listitem>
  347. <simpara><command>kea-dhcp-ddns.dhcp-to-d2</command> - this is the logger
  348. used by the kea-dhcp-ddns deamon for logging information about events
  349. dealing with receving messages from the DHCP servers and adding them
  350. to the queue for processing.</simpara>
  351. </listitem>
  352. <listitem>
  353. <simpara><command>kea-dhcp-ddns.d2-to-dns</command> - this is the logger
  354. used by the kea-dhcp-ddns deamon for logging information about events
  355. dealing with sending and receiving messages with the DNS servers.
  356. </simpara>
  357. </listitem>
  358. </itemizedlist>
  359. <para>
  360. Note that user-defined hook libraries should not use any of those
  361. loggers, and should define new loggers with names that correspond to
  362. the libraries using them. Suppose that the user created the library called
  363. <quote>libpacket-capture</quote> to dump packets received and
  364. transmitted by the server to the file. The appropriate name for the
  365. logger could be <command>kea-dhcp4.packet-capture</command>. Note
  366. that the hook library implementor only specifies the second part
  367. of this name, i.e. <quote>packet-capture</quote>. The first part is
  368. a root logger name and is prepended by the Kea logging system.
  369. It is also important to note that since this new logger is a child
  370. of a root logger, it inherits the configuration from the root logger,
  371. unless there is a separate configuration entry for the child logger
  372. which overrides the default configuration.
  373. </para>
  374. <para>
  375. The list of loggers above excludes any loggers implemented in hooks
  376. libraries. Please consult the documentation of the specific hooks
  377. libraries for the names of loggers they define.
  378. </para>
  379. <para>Additional loggers may be defined in the future. The easiest
  380. way to find out the logger name is to configure all logging to go
  381. to a single destination and look for specific logger names. See
  382. <xref linkend="logging-message-format"/> for details.</para>
  383. </section>
  384. <section>
  385. <title>severity (string)</title>
  386. <para>
  387. This specifies the category of messages logged.
  388. Each message is logged with an associated severity which
  389. may be one of the following (in descending order of
  390. severity):
  391. </para>
  392. <itemizedlist>
  393. <listitem>
  394. <simpara> FATAL </simpara>
  395. </listitem>
  396. <listitem>
  397. <simpara> ERROR </simpara>
  398. </listitem>
  399. <listitem>
  400. <simpara> WARN </simpara>
  401. </listitem>
  402. <listitem>
  403. <simpara> INFO </simpara>
  404. </listitem>
  405. <listitem>
  406. <simpara> DEBUG </simpara>
  407. </listitem>
  408. </itemizedlist>
  409. <para>
  410. When the severity of a logger is set to one of these
  411. values, it will only log messages of that severity, and
  412. the severities above it. The severity may also be set to
  413. NONE, in which case all messages from that logger are
  414. inhibited.
  415. <!-- TODO: worded wrong? If I set to INFO, why would it show DEBUG which is literally below in that list? -->
  416. </para>
  417. </section>
  418. <section>
  419. <title>output_options (list)</title>
  420. <para>
  421. Each logger can have zero or more
  422. <option>output_options</option>. These specify where log
  423. messages are sent. These are explained in detail below.
  424. </para>
  425. <para>
  426. The other options for a logger are:
  427. </para>
  428. </section>
  429. <section>
  430. <title>debuglevel (integer)</title>
  431. <para>
  432. When a logger's severity is set to DEBUG, this value
  433. specifies what debug messages should be printed. It ranges
  434. from 0 (least verbose) to 99 (most verbose).
  435. </para>
  436. <!-- TODO: complete this sentence:
  437. The general classification of debug message types is
  438. TODO; there's a ticket to determine these levels, see #1074
  439. -->
  440. <para>
  441. If severity for the logger is not DEBUG, this value is ignored.
  442. </para>
  443. </section>
  444. </section>
  445. <section>
  446. <title>Output Options</title>
  447. <para>
  448. The main settings for an output option are the
  449. <option>destination</option> and a value called
  450. <option>output</option>, the meaning of which depends on
  451. the destination that is set.
  452. </para>
  453. <section>
  454. <title>destination (string)</title>
  455. <para>
  456. The destination is the type of output. It can be one of:
  457. </para>
  458. <itemizedlist>
  459. <listitem>
  460. <simpara> console </simpara>
  461. </listitem>
  462. <listitem>
  463. <simpara> file </simpara>
  464. </listitem>
  465. <listitem>
  466. <simpara> syslog </simpara>
  467. </listitem>
  468. </itemizedlist>
  469. </section>
  470. <section>
  471. <title>output (string)</title>
  472. <para>
  473. This value determines the type of output. There are several
  474. special values allowed here: <command>stdout</command> (messages
  475. are printed on standard output), <command>stderr</command>
  476. (messages are printed on stderr), <command>syslog</command> (messages
  477. are logged to syslog using default name, <command>syslog:name</command>
  478. (messages are logged to syslog using specified name). Any other
  479. value is interpreted as a filename that the logs should be written to.
  480. </para>
  481. <para>
  482. The other options for <option>output_options</option> are:
  483. </para>
  484. <section>
  485. <title>flush (true of false)</title>
  486. <para>
  487. Flush buffers after each log message. Doing this will
  488. reduce performance but will ensure that if the program
  489. terminates abnormally, all messages up to the point of
  490. termination are output. Default is true.
  491. </para>
  492. </section>
  493. <section>
  494. <title>maxsize (integer)</title>
  495. <para>
  496. Only relevant when destination is file, this is maximum
  497. file size of output files in bytes. When the maximum
  498. size is reached, the file is renamed and a new file opened.
  499. (For example, a ".1" is appended to the name &mdash;
  500. if a ".1" file exists, it is renamed ".2",
  501. etc.)
  502. </para>
  503. <para>
  504. If this is 0, no maximum file size is used.
  505. </para>
  506. <note>
  507. <simpara>
  508. Due to a limitation of the underlying logging library
  509. (log4cplus), rolling over the log files (from ".1" to
  510. ".2", etc) may show odd results: There can be
  511. multiple small files at the timing of roll over. This
  512. can happen when multiple processes try to roll
  513. over the files simultaneously.
  514. Version 1.1.0 of log4cplus solved this problem, so if
  515. this or higher version of log4cplus is used to build
  516. Kea, it shouldn't happen. Even for older versions
  517. it is normally expected to happen rarely unless the log
  518. messages are produced very frequently by multiple
  519. different processes.
  520. </simpara>
  521. </note>
  522. </section>
  523. <section>
  524. <title>maxver (integer)</title>
  525. <para>
  526. Maximum number of old log files to keep around when
  527. rolling the output file. Only relevant when
  528. <option>output</option> is <quote>file</quote>.
  529. </para>
  530. </section>
  531. </section>
  532. </section>
  533. <section>
  534. <title>Example Logger Configurations</title>
  535. <para>
  536. In this example we want to set the global logging to
  537. write to the console using standard output.
  538. </para>
  539. <screen><userinput>
  540. "Logging": {
  541. "loggers": [
  542. {
  543. "name": "kea-dhcp4",
  544. "output_options": [
  545. {
  546. "output": "stdout"
  547. }
  548. ],
  549. "severity": "WARN"
  550. }
  551. ]
  552. }
  553. </userinput>
  554. </screen>
  555. <para>In this second example, we want to store debug log messages
  556. in a file that is at most 2MB and keep up to 8 copies of old logfiles.
  557. Once the logfile grows to 2MB, it will be renamed and a new file
  558. file be created.</para>
  559. <screen><userinput>
  560. "Logging": {
  561. "loggers": [
  562. {
  563. "name": "kea-dhcp6",
  564. "output_options": [
  565. {
  566. "output": "/var/log/kea-debug.log",
  567. "maxver": 8,
  568. "maxsize": 204800,
  569. "flush": true
  570. }
  571. ],
  572. "severity": "DEBUG",
  573. "debuglevel": 99
  574. }
  575. ]
  576. }</userinput></screen>
  577. </section>
  578. </section>
  579. <section id="logging-message-format">
  580. <title>Logging Message Format</title>
  581. <para>
  582. Each message written to the configured logging
  583. destinations comprises a number of components that identify
  584. the origin of the message and, if the message indicates
  585. a problem, information about the problem that may be
  586. useful in fixing it.
  587. </para>
  588. <para>
  589. Consider the message below logged to a file:
  590. <screen>2014-04-11 12:58:01.005 INFO [kea-dhcp4.dhcpsrv/27456]
  591. DHCPSRV_MEMFILE_DB opening memory file lease database: type=memfile universe=4</screen>
  592. </para>
  593. <para>
  594. Note: the layout of messages written to the system logging
  595. file (syslog) may be slightly different. This message has
  596. been split across two lines here for display reasons; in the
  597. logging file, it will appear on one line.
  598. </para>
  599. <para>
  600. The log message comprises a number of components:
  601. <variablelist>
  602. <varlistentry>
  603. <term>2014-04-11 12:58:01.005</term>
  604. <!-- TODO: timestamp repeated even if using syslog? -->
  605. <listitem><para>
  606. The date and time at which the message was generated.
  607. </para></listitem>
  608. </varlistentry>
  609. <varlistentry>
  610. <term>INFO</term>
  611. <listitem><para>
  612. The severity of the message.
  613. </para></listitem>
  614. </varlistentry>
  615. <varlistentry>
  616. <term>[kea-dhcp4.dhcpsrv/27456]</term>
  617. <listitem><para>
  618. The source of the message. This comprises two elements:
  619. the Kea process generating the message (in this
  620. case, <command>kea-dhcp4</command>) and the component
  621. within the program from which the message originated
  622. (which is the name of the common library used by DHCP server
  623. implementations). The number after the slash is a process id
  624. (pid).
  625. </para></listitem>
  626. </varlistentry>
  627. <varlistentry>
  628. <term>DHCPSRV_MEMFILE_DB</term>
  629. <listitem><para>
  630. The message identification. Every message in Kea
  631. has a unique identification, which can be used as an
  632. index into the <ulink
  633. url="kea-messages.html"><citetitle>Kea Messages
  634. Manual</citetitle></ulink> (<ulink
  635. url="http://kea.isc.org/docs/kea-messages.html"
  636. />) from which more information can be obtained.
  637. </para></listitem>
  638. </varlistentry>
  639. <varlistentry>
  640. <term>opening memory file lease database: type=memfile universe=4</term>
  641. <listitem><para>
  642. A brief description.
  643. Within this text, information relating to the condition
  644. that caused the message to be logged will be included.
  645. In this example, the information is logged that the in-memory
  646. lease database backend will be used to store DHCP leases.
  647. </para></listitem>
  648. </varlistentry>
  649. </variablelist>
  650. </para>
  651. </section>
  652. <section>
  653. <title>Logging During Kea Startup</title>
  654. <para>
  655. The logging configuration is specified in the configuration file.
  656. However, when Kea starts, the file is not read until some way into the
  657. initialization process. Prior to that, the logging settings are
  658. set to default values, although it is possible to modify some
  659. aspects of the settings by means of environment variables. Note
  660. that in the absence of any logging configuration in the configuration
  661. file, the settings of (possibly modified) default configuration will
  662. persist while the program is running.
  663. </para>
  664. <para>
  665. The following environment variables can be used to control the
  666. behavio of logging during startup:
  667. </para>
  668. <variablelist>
  669. <varlistentry>
  670. <term>KEA_LOCKFILE_DIR</term>
  671. <listitem><para>
  672. Specifies a directory where the logging system should create its
  673. lock file. If not specified, it is
  674. <replaceable>prefix</replaceable>/var/run/kea, where
  675. <replaceable>prefix</replaceable> defaults to /usr/local.
  676. This variable must not end
  677. with a slash. There is one special value: "none", which
  678. instructs Kea to not create lock file at all. This may cause
  679. issues if several processes log to the same file.
  680. </para></listitem>
  681. </varlistentry>
  682. <varlistentry>
  683. <term>KEA_LOGGER_DESTINATION</term>
  684. <listitem><para>
  685. Specifies logging output. There are several special values.
  686. <variablelist>
  687. <varlistentry>
  688. <term>stdout</term>
  689. <listitem><para>
  690. Log to standard output.
  691. </para></listitem>
  692. </varlistentry>
  693. <varlistentry>
  694. <term>stderr</term>
  695. <listitem><para>
  696. Log to standard error.
  697. </para></listitem>
  698. </varlistentry>
  699. <varlistentry>
  700. <term>syslog<optional>:<replaceable>fac</replaceable></optional></term>
  701. <listitem><para>
  702. Log via syslog. The optional
  703. <replaceable>fac</replaceable> (which is
  704. separated from the word "syslog" by a colon)
  705. specifies the
  706. facility to be used for the log messages. Unless
  707. specified, messages will be logged using the
  708. facility "local0".
  709. </para></listitem>
  710. </varlistentry>
  711. </variablelist>
  712. Any other value is treated as a name
  713. of the output file. If not specified otherwise, Kea will log to
  714. standard output.
  715. </para></listitem>
  716. </varlistentry>
  717. </variablelist>
  718. </section>
  719. </chapter>