Overview
This article explains how to enable and collect logs for the Traefik instance that M-Files Server installs and manages in on-premises installations.
This article assumes you have already followed this guide and fulfil the prerequisites there, otherwise this feature is not available. Do not perform this migration just to get the logs.
Switching from RPC to gRPC in an M-Files System.pdf.
These logs can be useful to troubleshoot network and connectivity issues and to, for example, confirm whether network traffic even reaches the M-Files Application server.
Notes
Before doing this, keep in mind the following:
- This process requires that you edit a configuration template that M-Files uses. Be very careful when doing so - syntax errors, mistakes or editing what you are not supposed to can cause issues in the system.
- Take a backup copy of the file before making changes.
- Make sure you are familiar with the Traefik tool itself and its logging options, capabilities and configurations. For example, review the Traefik documentation on logging: https://doc.traefik.io/traefik/observability/overview/
- The access logs can fill up the disk quickly, make sure to not keep them enabled for a long time, they can generate very large amounts of data.
- Traefik can and will reuse the file, so it will also lock it for writing. This means that you can open it for reading, but you may be unable to copy it to another location until Traefik stops writing to it (e.g., starts using a different file or stops logging).
- The user that Traefik runs under (the same as M-Files Server, by default it is SYSTEM), must have read, list and write access to that directory. Respective folders in the path must already exist.
- Upgrading M-Files server will rewrite this template and thus remove your changes.
- M-Files does not support changes to the M-Files Traefik configurations or issues that stem from them.
Solution
Step 1: Find and store the original configuration template
Go to this path:
C:\Program Files\M-Files\<version>\Server\traefik\templates
Take a backup copy elsewhere of the file
traefik_static.yml.template
Then, open the file from the M-Files installation folder in a text editor of your choice.
Step 2: Edit the logging configuration as desired
The default configuration for logging, at the time of writing, is near the end of the file.
You can edit it, for example, like this:
## Logging.
log:
level: WARN # can be DEBUG, INFO, WARN
filePath: 'C:\MFTraefikLogs\%TRAEFIK_LOG_PATH%' # make sure the folder exists and keep the %TRAEFIK_LOG_PATH% variable to use the default name. If you want to hardcode a file name, edit this.
format: common
maxSize: 5
maxBackups: 20
## Access log as needed.
# These next lines are commented (disabled) by default
accessLog:
filePath: 'C:\MFTraefikLogs\%TRAEFIK_ACCESS_LOG_PATH%' # make sure the folder exists and keep the %TRAEFIK_LOG_PATH% variable to use the default name. If you want to hardcode a file name, edit this.
format: common
Here is another example that filters the access log to skip 200 status codes that will usually be the bulk of traffic, so you can search more easily for errors. This one also hardcodes the file names.
## Logging.
log:
level: ERROR
filePath: 'C:\MFTraefikLogs\applog.txt'
format: common
maxSize: 5
maxBackups: 20
## Access log as needed.
accessLog:
filePath: 'C:\MFTraefikLogs\accessLog.txt'
format: common
filters:
statusCodes: "300-599"
Default paths and file names
Unless you set a folder of your own, the default path is
C:\Program Files\M-Files\<version>\Server\traefik\Logs
In versions 26.2 and earlier, the default path is
C:\Windows\System32\
The default file names are
traefikLog-<mfserver.exe process ID>.txt
traefikAccessLog-<mfserver.exe process ID>.txt
Step 3: Restart Traefik
This requires a short services break.
The easiest way to restart Traefik so the new configuration is taken into use is to:
- Open Task Manager.
- Find the "mf-traefik.exe" process.
- Press End Task button.
M-Files Server will detect that the process is not running anymore and will start it again. The connectivity break is short, a few seconds.
If you want to change the file name that is used, restart the M-Files Server Service instead - this will restart the entire M-Files Server and so it will get a new process ID. Note that this is usually a longer service break.
