"module file not found" when using file->file_size() or other file functions in Exec


#1 hukel (Last updated )

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-&gt;file_size() &gt; 10M)
    {
		$stagingFolder = 'E:/nxlog_output/staged/';
        $newfile = $stagingFolder + 'data_' + strftime(now(), '%Y%m%d%H%M%S') + '.log';
        file-&gt;rotate_to($newfile);
	}
&lt;/Exec&gt;

</Output>

 

#2 hukel
#1 hukel
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 errorERROR 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 errorsusing 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-&gt;file_size() &gt; 10M) { $stagingFolder = 'E:/nxlog_output/staged/'; $newfile = $stagingFolder + 'data_' + strftime(now(), '%Y%m%d%H%M%S') + '.log'; file-&gt;rotate_to($newfile); } &lt;/Exec&gt; </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-&gt;file_size() &gt; 10M)
    {
		$stagingFolder = 'E:/nxlog_output/staged/';
        $newfile = $stagingFolder + 'data_' + strftime(now(), '%Y%m%d%H%M%S') + '.log';
        activelog-&gt;rotate_to($newfile);
	}
&lt;/Exec&gt;

</Output>