Question: I am trying to get my build of QGIS to output the debug messages from calls to QgsDebugMsg. Here's what I have so far:

I've built QGIS configured as RelWithDebugInfo and in the application's `Help > About > About` window, I see the text: "This copy of QGIS writes debugging output."

In the application's `Options > System > Environment Variables` window, I've set the environment variables: `QGIS_DEBUG = 9` and `QGIS_LOG_FILE = C:\Users\USER\Documents\QGIS\log.txt`

However, the log file isn't getting created at all. What am I missing?

Answer: 
Answering for QGIS 3.4.1.

These variables are apparently being read too early in the QGIS startup cycle, so it doesn't work if you configure them through `Settings > Options > System > Environment Variables`.

Instead, you need to set them before QGIS starts. On Linux and macOS, use a command like this:

```
QGIS_DEBUG=9 QGIS_LOG_FILE=/tmp/qgis.log qgis

```

On Windows, presumably you'd do something like this in the command prompt:

```
set QGIS_DEBUG=9
set QGIS_LOG_FILE=C:\Users\USER\Documents\QGIS\log.txt
C:\path\to\qgis\qgis.exe

```
Qgis 3.10.5 seems to work when setting these variables via the options menu.

1) create an empty text file somewhere
2) in Qgis Settings > System > Environment add an entry for QGIS\_DEBUG and QGIS\_LOG\_FILE as shown
3) restart Qgis

[Settings](https://i.stack.imgur.com/npMup.png)