Community Edition - Failed to load module xm_python.dll
Running nxlog-ce-3.1.2319 on Windows.
2023-01-19 08:12:46 ERROR Failed to load module from C:\xxxxx\nxlog\modules\extension\xm_python.dll, The specified module could not be found. ; The specified module could not be found.
The NXLog Python DLL is on disk so I am wondering if this is complaining because I don't have the nxlog Python module (which I don't see in pip).I looked around for some setup instructions but I don't see any extra setup steps required for Python (aside from writing the script).
Config:<Extension python>
Module xm_python
PythonCode "C:\xxx\NXLogDev\modules\convert_to_splunk_hec.py"
</Extension>
PythonCode
import nxlog
def get_splunk_hec_format(event):
nxlog.log_warning('in get_splunk_hec_format()')
for field in event.field_names():
nxlog.log_debug('Received field:' + field)
Hello,
do you have python installed on Windows?
That's a separate required step. It needs python 3.10, and Python executable MUST be in PATH.
The python install and configuration script below has been tested w/ NXLog Enterprise Edition. It will be included in the next revision of NXLog Enterprise Edition documentation, and I will try to squeeze it into the Community Edition docs as well.
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$ver="3.10.8"
$baseuri="https://www.python.org/ftp/python/" + $ver
$msifile="python-" + $ver +"-amd64.exe"
Invoke-WebRequest -uri $baseuri/$msifile -OutFile $msifile
$sdotver=$ver -replace '([0-9]).([0-9]).([0-9]*)', '$1.$2'
$sver=$sdotver -replace '.',''
$pydll='C:\Program Files\Python' + $sver + '\python' + $sver + '.dll'
$nxpydll='C:\Program Files\nxlog\libpython' + $sdotver + '.dll'
& ./$msifile /quiet InstallAllUsers=1 PrependPath=1 CompileAll=1
DO
{
Start-Sleep -s 2
Write-Host -NoNewline .
}
until (Test-Path $pydll )
Write-Host
Write-Host "Copying DLL: $pydll -> $nxpydll"
cp $pydll $nxpydll
Manual steps:
- Download Python version 3.10 (I checked the version on nxlog-ce 3.1)
- Execute the installation wizard and in the first step, choose Customize installation.
- Set “install for all users”
- Set “Add python to environment variables”
- Take note of the install location and click Install.
- When the installation is complete, open the Python installation folder.
- Copy the Python DLL, e.g.,
python310.dll
, to the NXLog installation folder. - Rename the file to
libpython<major_version>.<minor_version>.dll
. See the table below. - Restart the NXLog service.
This is what the script above tries to do.
Let me know how it goes!
Gabor