# Feature request: CTEST - Individual log files per test

**URL:** https://discourse.cmake.org/t/feature-request-ctest-individual-log-files-per-test/8425
**Category:** Development
**Created:** [June 28, 2023, 5:06pm UTC](https://discourse.cmake.org/t/feature-request-ctest-individual-log-files-per-test/8425 "2023-06-28T17:06:26Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![0xEvie](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/0/6bbea6/32.png) [@0xEvie](https://discourse.cmake.org/u/0xEvie)
#### Post date: [June 28, 2023, 5:06pm UTC](https://discourse.cmake.org/t/feature-request-ctest-individual-log-files-per-test/8425/1 "2023-06-28T17:06:26Z")

</div>

Hey there,

**Summary:**  
CTest outputs one unified log file when running “-O output.log”.  
I would love to see an option where you could generate a log file per CTest test into a log directory.  
It would be particularly helpful to generate log files for only failing tests.  
This would keep the test report clear and concise, but enable debugging.

**Behaviour:**  
Turned on via a command line argument.

```auto
--log-per-test

```

Each test output log would go to a log directory, under testname.log

```auto
logs/test_name0.log
logs/test_name1.log
logs/test_name2.log

```

CTest would create a log file for EACH test, i.e. STD OUT or test output redirects to a log file all the time  
OR  
Create a log for each failing test only

The output report would report the failing tests like so:

```auto
The following tests FAILED:
	  1 - bf16_test0 (Failed)
               Log: (<full_path>/logs/bf16_test0.log)
	  2 - bf16_test1(Failed)
                Log: (<full_path>/logs/bf16_test1.log)

```

**Options**  
Also here’s some options that would be nice to see

1. Define log directory:  
Gives the user the option to define a log directory, for when logging is.  
(A better naming convention I think would work better I think)

```auto
--log-per-test-dir logs/custom_dir

```

or using a CTest CMake environment variable:

```auto
set(CTEST_PER_TEST_LOG_DIRECTORY, "<something>")

```

1. Create a log file only for failing tests  
Gives the user the option to define a log directory, for when logging is.

```auto
--log-on-failure-only

```

or using a CTest CMake environment variable:

```auto
set(CTEST_LOG_PER_TEST_ON_FAILURE_ONLY, "<something>")

```

This feature would help adoption in my organization. Particularly for CI applications

Thanks.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [July 1, 2023, 9:33pm UTC](https://discourse.cmake.org/t/feature-request-ctest-individual-log-files-per-test/8425/2 "2023-07-01T21:33:38Z")

</div>

I agree with the feature. However, please keep in mind that `ctest_test()` should also gain access to these so that CTest scripts can utilize the functionality as well.

---

<div class="post-metadata">

### Author: ![0xEvie](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/0/6bbea6/32.png) [@0xEvie](https://discourse.cmake.org/u/0xEvie)
#### Post date: [July 3, 2023, 11:14am UTC](https://discourse.cmake.org/t/feature-request-ctest-individual-log-files-per-test/8425/3 "2023-07-03T11:14:54Z")

</div>

Yes for sure!

Is this the correct place to define feature requests or must I add them to gitlab issues tracker?

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [July 3, 2023, 10:18pm UTC](https://discourse.cmake.org/t/feature-request-ctest-individual-log-files-per-test/8425/4 "2023-07-03T22:18:30Z")

</div>

Thanks for asking where to do what, we appreciate the care. 🙂

The forums should be used for asking questions, clarifying things and general discussion about CMake. Feel free to discuss your idea further here if there are aspects you are not sure about yet. Once you have a clear idea of the feature you want to propose, please open a new issue in gitlab with your proposal. It can still be discussed further there, but if it starts out in gitlab with an already clear focus and explanation, that will improve its chances of being actioned by someone with the time and interest.

---

<div class="post-metadata">

### Author: ![0xEvie](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/0/6bbea6/32.png) [@0xEvie](https://discourse.cmake.org/u/0xEvie)
#### Post date: [July 14, 2023, 12:54pm UTC](https://discourse.cmake.org/t/feature-request-ctest-individual-log-files-per-test/8425/5 "2023-07-14T12:54:35Z")

</div>

I added a gitlab issue (with simplified and thought out actions).  
Could a “triage:feature:” label be applied to it?

[https://gitlab.kitware.com/cmake/cmake/-/issues/25090](https://gitlab.kitware.com/cmake/cmake/-/issues/25090)
