---
title: "Capturing Console Output in xUnit.v3"
description: "In xUnit `v2` `ITraceOutputHelper` was needed (and injected) to make the console output inside your production code visible inside a test - in `v3` it is easier: `CaptureConsoleAttribute`"
updated: 2025-11-10
tags: ["xUnit"]
canonical: "https://steven-giesel.com/blogPost/63a50c08-ddba-4f23-9ce0-b47917e32875/capturing-console-output-in-xunitv3"
---

# Capturing Console Output in xUnit.v3

In xUnit `v2` `ITraceOutputHelper` was needed (and injected) to make the console output inside your production code visible inside a test - in `v3` it is easier: `CaptureConsoleAttribute`

## `CaptureConsoleAttribute`

All what I am writing here, can be found in the official documentation: https://xunit.net/docs/capturing-output

The gist here:
```csharp
// Both standard output and standard error
[assembly: CaptureConsole]

// Only standard output
[assembly: CaptureConsole(CaptureError = false)]

// Only standard error
[assembly: CaptureConsole(CaptureOutput = false)]
```

As this is an assembly wide attribute, you only have to define this once. While easier to setup for your project, you lose the fine-grained control of `v2`. As of now (10th of November 2025), [the attribute is defined as](https://github.com/xunit/xunit/blob/main/src/xunit.v3.core/CaptureConsoleAttribute.cs):
```csharp
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false, Inherited = false)]
public sealed class CaptureConsoleAttribute : Attribute, IAssemblyFixtureAttribute
```

So you can't slap it on a class or method.