Knowledge Base
Searching in : Document
ID: DT11R00182
Version: NoMachine 7
Added on: 2020-11-13
Last Update: 2020-12-17
Print this article

Collect server side logs automatically

Table of Contents
Introduction
Collect NoMachine Logs
1. Short Instructions
2. Detailed Instructions
Appendix
3. Collect Specific Logs by Running a Custom Script
4. How to Clean-Up Logs

Introduction

NoMachine servers provide command line tools to enable debug log level, collect the necessary logs and create a compressed archive ready to be sent to the Support Team. These tools are run by the 'nxserver --debug' and relative options.

The 'nxserver --debug' commands used in the following instructions have to be executed from command line in a terminal on Linux and Mac or a CMD console on Windows.

Administrative privileges are requested to run it: launch it with sudo on Linux and Mac or without sudo and as root; on Windows open a CMD console executed as administrator.

Client side logs
About client side logs, when the connection terminates with an error, the client shows a short error message and asks to save logs of that problem into a directory.
Otherwise, if requested by the Support Team, it's necessary to collect them manually as explained in the next paragraphs or in the document linked above.

Multi-host environment
In case of multi-host environments, the 'nxserver --debug' tools must be run on the main server and on the problematic host where the issue occurred. For example, in a multi-node environment made of a main server ETS and two nodes TSN1 and TSN2, if the session cannot be started on the second node it will be necessary to run the 'nxserver --debug' commands on ETS and also on TSN2 to gather logs from both machines.

Logging to syslog
The 'nxserver --debug' tools cannot be used to collect logs written to system log.
When server and/or node and/or web player are configured to log to the system log, it's necessary to collect manually the nx* log entries from journalctl or from syslog. For example:

journalctl -b -0 | grep -i "nxserver\|nxnode\|nxwebplayer" > journalctl.extract
or:
grep "nxserver\|nxnode\|nxwebplayer" /var/log/SYSLOGFILE > syslog.extract
where SYSLOGFILE is the system log file.
TIP
In case of sudden termination of nx* processes, it's still necessary to retrieve the related core file and debug it as explained in the chapter about How to Gather a Stacktrace in the guide for collecting logs manually https://www.nomachine.com/DT11R00181
Collect NoMachine Logs
1. Short Instructions

1) Enable debug level on the problematic machine:

nxserver --debug --enable all

2) Connect and reproduce the problem.

3) Create the log archive:

nxserver --debug --collect

4) Collect client side logs (if requested)

5) Send logs to Support Team as e-mail attachment (keep the ticket ID in the subject).

6) Restore Informational log level:

nxserver --debug --disable all
TIP
When the problem is easily reproducible or if the Support Team requested that, you may clean the logs before starting the procedure above to collect them:
nxserver --logrotate
2. Detailed Instructions

Command 'nxserver --debug --enable' allows to gather debug logs for all components: nxserver, nxnode, nxwebplayer/client and the display agent. Execute it on the machine where the problem occurs.

This command edits the server.cfg file and sets:
SessionLogLevel 7
WebSessionLogLevel 7

It also edits node.cfg and sets:
SessionLogLevel 7
SessionLogClean 0

NoMachine server and services are not restarted. Old sessions continue to run. The debug settings will apply only to new sessions.

First Step: Enable Debug Level on the Problematic Host
Linux and Mac
sudo /etc/NX/nxserver --debug --enable all

If you are the root user, run the command above without 'sudo'.

Windows

To enable debug on Windows, open a CMD console as administrator and move to the 'bin' folder under the NoMachine installation, e.g:

cd %ProgramFiles(x86)%\NoMachine\bin
nxserver --debug --enable all
TIP
Depending on the problem, it could be useful to enable debug for a specific target only. This is in general specified by the Support Team when needed. Multiple targets can be specified in a comma-separated list:
nxserver --debug --enable server,node
nxserver --debug --enable webplayer
nxserver --debug --enable agent
Second Step: Connect and Reproduce the Problem

The debug level applies to new sessions only: create a new session and try to reproduce the problem.

TIP
If client side logs are also requested, be sure that the Don't delete log files on exit checkbox is selected in the client user's interface in the Settings -> Player -> Security panel on the end-user's computer.
In case of web sessions, if browser's side logs are also requested, please follow instructions from the guide to collect logs manually: https://www.nomachine.com/DT11R00181 - Collect and send client side logs, for browsers.
Third Step: Create the Log Archive

Once the problem is reproduced, collect logs and generate the log archive to be sent to the Support Team.

Linux and Mac
sudo /etc/NX/nxserver --debug --collect

If you are the root user, run the command above without 'sudo'.

The log archive is named as: NoMachine-log-<timestamp>.zip (e.g. NoMachine-log-2018.09.27-11.44.01.zip) and stored in: /usr/NX/var/log/archives or /Library/Application Support/NoMachine/var/log/archives on Linux and Mac respectively.

Windows
cd %ProgramFiles(x86)%\NoMachine\bin
nxserver --debug --collect

The log archive is named as: NoMachine-log-<timestamp>.zip (e.g. NoMachine-log-2018.09.27-11.44.01.zip) and stored in: %PROGRAMDATA%/NoMachine/var/log/archives on Windows 10, 8.x, 7 and Vista or in Documents and Settings/All Users/NoMachine/var/log/archives Windows XP.

Fourth Step: Collect Client Side Logs (if requested)

Be sure that the client has been launched with the 'Don't delete log files on exit' option enabled in Settings -> Player -> Security. Otherwise the client logs will be missing or only partial.

On the user's computer, create a compressed archive of the .nx directory in the user's home.

Linux
sudo tar -cvp --exclude 'cache*' --exclude 'images' --exclude 'temp' -f - path_to_user_home/.nx | gzip -c nxdir.tar.gz

If you are the owner of the user's home, execute command above without 'sudo'.

TIPS
I If UserNXDirectoryPath is set in node.cfg, the .nx directory is created under a directory named as username in the path specified by such key.

Use this path in command above to create the log archive.

II When the users' home directories are NFS mounted and the squash_root option is set in NFS, add the "-u $user" to command:
sudo -u USERNAME tar -cvp --exclude 'cache*' --exclude 'images' --exclude 'temp' -f - path_to_user_home/.nx | gzip -c nxdir.tar.gz
Mac

On Mac, navigate with the Finder till the .nx directory. To reduce the size of the archive, remove cache, images and recording sub-directories under .nx before creating the compressed folder.

Compress this folder: control-click or right-click the folder and then choose 'Create Archive' from the pop-up menu.

Windows

On Windows the .nx folder is hidden. To find it, write the following in the address bar or the file browser:

%USERPROFILE%\.nx

Otherwise navigate through the computer folder till the user's home and digit .nx in the navigation toolbar to reach it. Path can be similar to: C:/Users/nomachine/.nx

To reduce the size of the archive, remove cache, images and recording sub-directories under .nx before creating the compressed folder.

Fifth Step: Send Logs to Support Team

Send via e-mail to the Support Team (as e-mail attachment):
a) the NoMachine-log archive from the server side
b) the compressed .nx directory from the user's home on his/her computer (if requested)

Please be sure to include ID of the enquiry in the subject of your e-mail to Support Team!

If the size of the log archive doesn't allow to send it by email, inform the Support Team who may provide an upload space for that.

Sixth Step: Restore Informational Level (Disable Debug Level)

Once logs have been retrieved, it's advisable to restore the Informational Log level to reduce the size of logs that will be printed.

Linux and Mac
sudo /etc/NX/nxserver --debug --disable all
Windows
cd %ProgramFiles(x86)%\NoMachine\bin
nxserver --debug --disable all
3. Collect Specific Logs by Running a Custom Script

The 'nxserver --debug --collect' procedure allows also to run custom scripts for including the output of specific command (e.g. run nxserver --list, --history, --nodelist etc ...).

Place the custom debug script in the NoMachine installation dir/scripts/log/ directory and follow the same procedure described in the paragraph above.

The 'nxserver --debug --collect' procedure will set correct permissions to the custom script and execute it before collecting logs as usual.

4. How to Clean-Up Logs

It's possible to clean up log files before proceeding to set debug level, reproduce the problem and collect the logs. This will help to reduce the size of logs and focus on the problem (if easily reproducible).

To do that, force the rotation of NoMachine logs by executing:

Linux and Mac
sudo /etc/NX/nxserver --logrotate

If you are the root user, run the command above without 'sudo'.

Windows
cd %ProgramFiles(x86)%\NoMachine\bin
nxserver --logrotate

Rotated files are saved in the NoMachine var/log/logrotate directory:
/usr/NX/var/log on Linux
%PROGRAMDATA%/NoMachine/var/log on Windows
/Library/Application Support/NoMachine/var/log on macOS
and named as:
nxserver.log-user for log archive from user's home/.nx
nxserver.log for log archive from NoMachine's var/log/