24. Reading and Receiving Logs
This chapter discusses log sources that you may need to use with NXLog, including:
-
log data received over the network,
-
events stored in databases,
-
messages read from files, and
-
data retrieved using executables.
24.1. Receiving over the Network
This section provides information and examples about receiving log messages from the network over various protocols.
- UDP
-
The im_udp module handles incoming messages over UDP.
Example 47. Using the im_udp ModuleThis input module instance shows the im_udp module configured with the default options: localhost only and port 514.
NoteThe UDP protocol does not guarantee reliable message delivery. It is recommended to use the TCP or SSL transport modules instead if message loss is a concern.
Though NXLog was designed to minimize message loss even in the case of UDP, adjusting the kernel buffers may reduce the likelihood of UDP message loss on a loaded system. The Priority directive in the Route block can also help.
- Syslog
-
To receive Syslog over the network, use one of the network modules above, coupled with xm_syslog. Syslog parsing is not required if you only need to forward or store the messages as they are. See also Accepting Syslog via UDP, TCP, or TLS.
Example 50. Receiving Syslog over TCP with Octet-FramingWith this example configuration, NXLog listens for messages on TCP port 1514. The xm_syslog extension module provides the Syslog_TLS InputType (for octet-framing) and the parse_syslog() procedure for parsing Syslog messages.
24.2. Reading from a Database
With the im_dbi and im_odbc modules it is possible to read logs directly from database servers. The im_dbi module can be used on POSIX systems where libdbi is available. The im_odbc module, available in NXLog Enterprise Edition, can be used with ODBC compatible databases on Windows, Linux, and Unix.
This example uses libdbi and the MySQL driver to read records from
the logdb
database.
24.3. Reading from Files and Sockets
- Files
-
The im_file module can be used to read logs from files. See also Reading Syslog Log Files.
- Unix Domain Socket
-
Use the im_uds module to read from a Unix domain socket. See also Accepting Syslog via /dev/log.
Example 54. Using the im_uds ModuleWith this configuration, NXLog will read messages from the
/dev/log
socket. NXLog’s flow control feature must be disabled in this case (see the FlowControl directive in the Reference Manual).
24.4. Receiving from an Executable
The im_exec module can be used to read logs from external programs and scripts over a pipe.