Collect server side logs automatically

Added on: 2017-11-15 Last Modified: 2019-10-08
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 (from v. 6.5)


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.

The 'nxserver --debug' tools cannot be used to collect logs written to system log. In this case, extract them from the system log, you may look for the 'NX' key word (e.g. on Linux: grep NX /var/log/messages > syslog.extract)

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.

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.

When server and/ore node 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.


TIPS
Since NoMachine v. 6.3, the 'nxserver --debug' tools allow to gather also logs of the NoMachine display agent. Such logs are relevant to debug issues like visual artifacts, slowness, unclean termination of the session etc ...

Note that 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 here: https://www.nomachine.com/DT10O00163
Since NoMachine v. 6.5, a new server command allows to force log rotation of NoMachine log files. Execute 'nxserver --logrotate' before the procedure for collecting logs in order to gather new fresh logs at debug level and related to the specific problem.


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
The --logrotate option is available from v. 6.5 onward.
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, move to the 'bin' folder under the NoMachine installation and execute:

nxserver --debug --enable all


TIP
Depending on the problem, it could be useful to enable debug for a specific target only. 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 -> Privacy panel on the end-user's computer.
In case of web sessions, if browser's side logs are also requested, please follow instructions here: https://www.nomachine.com/DT10O00163


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

If you are on Windows, move to the 'bin' folder under the NoMachine installation and execute:

nxserver --debug --collect

The log archive is 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)

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!



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

If you are on Windows, move to the 'bin' folder under the NoMachine installation and execute:

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 (from v. 6.5)

If you're running NoMachine server v. 6.5 or later, 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

Move to the 'bin' folder under the NoMachine installation and execute:

nxserver --logrotate

Rotated files are saved in the NoMachine var/log/logrotate directory:
/usr/NX/log/logrotate on Linux
/Library/Application\ Support/NoMachine/var/log/logrotate on Mac
%PROGRAMDATA%\NoMachine\var\log on Windows