logging.xml 36 KB

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