General settings
You can use the following directives throughout the configuration file. The NXLog Agent configuration parser processes these directives and substitutes values before loading the configuration.
- define
 - 
Use this directive to configure a constant or macro to be used later. Refer to a
defineby surrounding the name with percent signs (%). Enclose a group of statements with curly braces ({}).Example 1. Using the define DirectiveThis configuration shows three defines:
BASEDIRis a constant,IMPORTANTis a statement, andWARN_DROPis a group of statements.nxlog.confdefine BASEDIR /var/log define IMPORTANT if $raw_event =~ /important/ \ $Message = 'IMPORTANT ' + $raw_event; define WARN_DROP { log_warning("dropping message"); drop(); } <Input messages> Module im_file File '%BASEDIR%/messages' </Input> <Input proftpd> Module im_file File '%BASEDIR%/proftpd.log' <Exec> %IMPORTANT% if $raw_event =~ /dropme/ %WARN_DROP% </Exec> </Input> 
- envvar
 - 
This directive works like define, except that the value is retrieved from the environment.
Example 2. Using the envvar DirectiveThis example is like the previous one, but
BASEDIRis fetched from the environment instead.nxlog.confenvvar BASEDIR <Input file> Module im_file File '%BASEDIR%/messages' </Input> 
- include
 - 
This directive allows a specified file or files to be included in the current NXLog Agent configuration. Wildcarded filenames are supported.
The SpoolDir directive only takes effect after the configuration is parsed, so relative paths specified with the include directive must be relative to the NXLog Agent working directory. The examples below provide various ways of using the include directive.
Example 3. Using the include DirectiveThis example includes a file relative to the working directory.
nxlog.confinclude modules/module1.confIn case multiple
.conffiles are to be defined, they can be saved in thenxlog.ddirectory and then automatically included in the NXLog Agent configuration along with thenxlog.conffile. Adding.conffiles in thenxlog.ddirectory extends the NXLog Agent configuration, without needing to modify the mainnxlog.conffile.This solution could be useful to specify OS-specific configuration snippets (like windows2003.conf) or application-specific snippets (such assyslog.conf).Including subdirectories inside the configuration directory is not supported.
Example 4. Including Files With Wildcarded NamesThis example includes all matching files from the
nxlog.ddirectory and uses absolute paths on Unix-like systems and Windows.nxlog.confinclude /etc/nxlog.d/*.confnxlog.confinclude C:\Program Files\nxlog\conf\nxlog.d\*.conf 
- include_stdout
 - 
Use this directive to load dynamic configuration from the standard output of a command or script. include_stdout behaves like a command-line interface and accepts a path to a command or script file. It does not support arguments or execution of external scripts, such as PowerShell, directly. However, you can encapsulate scripts in a command file.
Example 5. Using the include_stdout directiveThis example executes a bash script to load dynamic NXLog Agent configuration.
nxlog.confinclude_stdout /opt/nxlog/etc/fetch_conf.sh 
- setenv
 - 
This directive sets an environment variable for the nxlog process. The value must be in the format
<VAR_NAME>=<VAR_VALUE>.Example 6. Using the setenv directiveThis example creates an environment variable named
KRB5_KTNAMEand assigns it the valueC:\Program Files\nxlog\krb\krb5.keytab.nxlog.confsetenv KRB5_KTNAME=C:\Program Files\nxlog\krb\krb5.keytab