NXLog User Guide
- OS Support
- Enterprise Edition Reference Manual
- 143. Man Pages
- 144. Configuration
- 145. Language
- 146. Extension Modules
- 147. Input Modules
- 148. Processor Modules
- 149. Output Modules
- 149.1. Microsoft Azure (om_azure)
- 149.2. Batched compression (om_batchcompress)
- 149.3. Blocker (om_blocker)
- 149.4. DBI (om_dbi)
- 149.5. Elasticsearch (om_elasticsearch)
- 149.6. EventDB (om_eventdb)
- 149.7. Program (om_exec)
- 149.8. File (om_file)
- 149.9. Go (om_go)
- 149.10. HTTP(s) (om_http)
- 149.11. Java (om_java)
- 149.12. Kafka (om_kafka)
- 149.13. Null (om_null)
- 149.14. ODBC (om_odbc)
- 149.15. Perl (om_perl)
- 149.16. Named pipes (om_pipe)
- 149.17. Python (om_python)
- 149.18. Raijin (om_raijin)
- 149.19. Redis (om_redis)
- 149.20. Ruby (om_ruby)
- 149.21. TLS/SSL (om_ssl)
- 149.22. TCP (om_tcp)
- 149.23. UDP (om_udp)
- 149.24. UDP with IP spoofing (om_udpspoof)
- 149.25. Unix domain sockets (om_uds)
- 149.26. WebHDFS (om_webhdfs)
- 149.27. ZeroMQ (om_zmq)
- NXLog Manager
- NXLog Add-Ons
The Perl programming language is widely used for log processing and comes with a broad set of modules bundled or available from CPAN. Code can be written more quickly in Perl than in C, and code execution is safer because exceptions (croak/die) are handled properly and will only result in an unfinished attempt at log processing rather than taking down the whole NXLog process.
|To examine the supported platforms, see the list of installer packages in the Available Modules chapter.|
The module will parse the file specified in the PerlCode directive when NXLog starts the module. The Perl code must implement the write_data subroutine which will be called by the module when there is data to process. This subroutine is called for each event record and the event record is passed as an argument. To access event data, the Log::Nxlog Perl module must be included, which provides the following methods.
|To use the om_perl module on Windows, a separate Perl environment must be installed, such as Strawberry Perl. Currently, the om_perl module on Windows requires Strawberry Perl 18.104.22.168.|
Send the message msg to the internal logger on DEBUG log level. This method does the same as the log_debug() procedure in NXLog.
Send the message msg to the internal logger on INFO log level. This method does the same as the log_info() procedure in NXLog.
Send the message msg to the internal logger on WARNING log level. This method does the same as the log_warning() procedure in NXLog.
Send the message msg to the internal logger on ERROR log level. This method does the same as the log_error() procedure in NXLog.
- get_field(event, key)
Retrieve the value associated with the field named key. The method returns a scalar value if the key exists and the value is defined, otherwise it returns undef.
For the full NXLog Perl API, see the POD documentation in
Nxlog.pm. The documentation can be read with
The om_perl module accepts the following directives in addition to the common module directives.
This mandatory directive expects a file containing valid Perl code. This file is read and parsed by the Perl interpreter.Note
On Windows, the Perl script invoked by the PerlCode directive must define the Perl library paths at the beginning of the script to provide access to the Perl modules.nxlog-windows.pl
use lib 'c:\Program Files\nxlog\data';
This optional directive allows you to pass configuration strings to the script file defined by the PerlCode directive. This is a block directive and any text enclosed within
<Config></Config>is submitted as a single string literal to the Perl code.Note
If you pass several values using this directive (for example, separated by the
\ndelimiter) be sure to parse the string correspondingly inside the Perl code.
This optional directive specifies the Perl subroutine to invoke. With this directive, you can call only specific subroutines from your Perl code. If the directive is not specified, the default subroutine
This output module sends events to the Perl script, which simply writes the
data from the
$raw_event field into a file.
1 2 3 4 5 <Output out> Module om_perl PerlCode "modules/output/perl/perl-output.pl" Call write_data1 </Output>