In nrf connect for vscode, how to store the project build log in a file

I would like to automatically save the contents of the log that `west` outputs to the terminal for a project build to a .log file;

When I click on `build` under the `action` column of `nrf connect for vscode`, I see that the code that is executed is :

"C:\windows\system32\cmd.exe /d /s /c "west build --build-dir e:/ nordic/nordic-connect-sdk-demo/Peripherals/15_usb/usb_hid_transparent/build e:/nordic/nordic-connect-sdk-demo/Peripherals/15_usb/ usb_hid_transparent --pristine --board nrf52840dk_nrf52840 --no-sysbuild -- -DNCS_TOOLCHAIN_VERSION=NONE -DCACHED_CONF_FILE=e:/nordic/ nordic-connect-sdk-demo/Peripherals/15_usb/usb_hid_transparent/prj.conf"

I would like to be able to add " > build.log 2>&1" at the end of the execution.

This is what it looks like.

"C:\windows\system32\cmd.exe /d /s /c "west build --build-dir e:/nordic/nordic-connect-sdk-demo/Peripherals/15_usb/usb_hid_transparent --pristine --nordic/nordic-connect-sdk-demo/Peripherals/15_usb/usb_hid_transparent transparent/build e:/nordic/nordic-connect-sdk-demo/Peripherals/15_usb/usb_hid_transparent --pristine --board nrf52840dk_nrf52840 --no- sysbuild -- -DNCS_TOOLCHAIN_VERSION=NONE -DCACHED_CONF_FILE=e:/nordic/nordic-connect-sdk-demo/Peripherals/15_usb/usb_hid_transparent/ prj.conf  > build.log 2>&1"

I've tried it, and if I run this code directly from the command line, it produces a `build.log` file that I want;

However, I'd like to be able to change the configuration of `nrf connect for vscode` to generate this `build.log` file every time I click on `build` under the `action` column of `nrf connect for vscode`.

I hope I can get your help. Thank you.

  • Hi,

    You could start by looking at VS Code Tasks and Binding Custom Tasks to Actions.

    Best regards,
    Dejan

  • Thank you for your patience in replying, I've read it and learnt how to customise the build's task and multiple tasks; however, I still haven't found how to implement the output of the build process log to a file, I hope you can provide further support;

  • Hi,

    Could you show what you have tried so far? What are the results?

    Best regards,
    Dejan

  • I tried the following scenario

    Modify the Action Build pointers in nRF Connect for VScode.
    Add the task in "tasks.json" as follows

    Change the "taskName" of "build" to the name of our task, as follows:

    Here is the contents of my test.cmd:

    In this way, I can realize that all the contents of west's logs are output to the build.log file

    However, the cmd file that executes the west command in this way is written manually by me.

    In this way, I wrote the cmd file for executing west commands manually, and I would prefer to replace it with nrf connect for vscode, which uses the "Build: usb_hid_transparent/build (active)" task according to my configuration to save the output log to a file.

  • Hi,

    Could you elaborate and show the difference of what you managed to achieve and what you prefer?

    Best regards,
    Dejan

1 2