"module file not found" when using file->file_size() or other file functions in Exec
I am trying to use the example in https://docs.nxlog.co/ce/current/index.html#om_file for file rotation on Windows (nxlog-ce-3.1.2319).
I receive the following error
ERROR Couldn't parse Exec block at xxx.conf:104; couldn't parse statement at line 107, character 29 in xxx.conf; module file not found
ERROR module 'testfile' has configuration errors
using this configuration. The output works fine if I don't use the functions, so I assume om_file must be loading (by default?).
<Output testfile>
Module om_file
File "E:/nxlog_output/active/nxlog-out.txt"
<Exec>
# Format output
to_json();
# Rotate file based on size, move to staging folder
if (file->file_size() > 10M)
{
$stagingFolder = 'E:/nxlog_output/staged/';
$newfile = $stagingFolder + 'data_' + strftime(now(), '%Y%m%d%H%M%S') + '.log';
file->rotate_to($newfile);
}
</Exec>
</Output>
I figured it out. This was my unfamiliarity with modules. I needed to refer to my own Output module by its name. That is the object whose file_size() function was being called.
<Output activelog>
Module om_file
File "E:/nxlog_output/active/nxlog-out.txt"
<Exec>
# Format output
to_json();
# Rotate file based on size, move to staging folder
if (activelog->file_size() > 10M)
{
$stagingFolder = 'E:/nxlog_output/staged/';
$newfile = $stagingFolder + 'data_' + strftime(now(), '%Y%m%d%H%M%S') + '.log';
activelog->rotate_to($newfile);
}
</Exec>
</Output>