TestLoggingContainer - Gradle DSL Version 8.12

# TestLoggingContainer

API Documentation: | `TestLoggingContainer`

Container for all test logging related options. Different options can be set for each log level. Options that are set directly (without specifying a log level) apply to log level LIFECYCLE. Example:

    apply plugin: 'java'

    test {
        testLogging {
            // set options for log level LIFECYCLE
            events("failed")
            exceptionFormat = "short"

            // set options for log level DEBUG
            debug {
                events("started", "skipped", "failed")
                exceptionFormat = "full"
            }

            // remove standard output/error logging from --info builds
            // by assigning only 'failed' and 'skipped' events
            info.events = ["failed", "skipped"]
        }
    }

The defaults that are in place show progressively more information on log levels WARN, LIFECYCLE, INFO, and DEBUG, respectively.

### Properties

Property | Description
`debug` | Returns logging options for debug level.
`displayGranularity` | The display granularity of the events to be logged. For example, if set to 0, a method-level event will be displayed as "Test Run > Test Worker x > org.SomeClass > org.someMethod". If set to 2, the same event will be displayed as "org.someClass > org.someMethod".
`error` | Returns logging options for error level.
`events` | The events to be logged.
`exceptionFormat` | The format to be used for logging test exceptions. Only relevant if `showStackTraces` is `true`. Defaults to `TestExceptionFormat.FULL` for the INFO and DEBUG log levels and `TestExceptionFormat.SHORT` for the LIFECYCLE log level.
`info` | Gets logging options for info level.
`lifecycle` | Returns logging options for lifecycle level.
`maxGranularity` | The maximum granularity of the events to be logged. Typically, 0 corresponds to the Gradle-generated test suite for the whole test run, 1 corresponds to the Gradle-generated test suite for a particular test JVM, 2 corresponds to a test class, and 3 corresponds to a test method. These values may extend higher if user-defined suites or parameterized test methods are executed. Events from levels higher than the specified granularity will be ignored.
`minGranularity` | The minimum granularity of the events to be logged. Typically, 0 corresponds to events from the Gradle-generated test suite for the whole test run, 1 corresponds to the Gradle-generated test suite for a particular test JVM, 2 corresponds to a test class, and 3 corresponds to a test method. These values may extend higher if user-defined suites or parameterized test methods are executed. Events from levels lower than the specified granularity will be ignored.
`quiet` | Returns logging options for quiet level.
`showCauses` | Tells whether causes of exceptions that occur during test execution will be logged. Only relevant if `showExceptions` is `true`. Defaults to true.
`showExceptions` | Tells whether exceptions that occur during test execution will be logged. Typically these exceptions coincide with a "failed" event. Defaults to true.
`showStackTraces` | Tells whether stack traces of exceptions that occur during test execution will be logged. Defaults to true.
`showStandardStreams` | Tells whether output on standard out and standard error will be logged. Equivalent to checking if both log events `TestLogEvent.STANDARD_OUT` and `TestLogEvent.STANDARD_ERROR` are set.
`stackTraceFilters` | The set of filters to be used for sanitizing test stack traces.
`warn` | Gets logging options for warn level.

### Methods

No methods

### Script blocks

No script blocks

### Property details

#### `TestLogging` `debug`

Returns logging options for debug level.

#### `int` `displayGranularity`

The display granularity of the events to be logged. For example, if set to 0, a method-level event will be displayed as "Test Run > Test Worker x > org.SomeClass > org.someMethod". If set to 2, the same event will be displayed as "org.someClass > org.someMethod".

-1 denotes the highest granularity and corresponds to an atomic test.

#### `TestLogging` `error`

Returns logging options for error level.

#### ``Set`<`TestLogEvent`>` `events`

The events to be logged.

#### `TestExceptionFormat` `exceptionFormat`

The format to be used for logging test exceptions. Only relevant if `showStackTraces` is `true`. Defaults to `TestExceptionFormat.FULL` for the INFO and DEBUG log levels and `TestExceptionFormat.SHORT` for the LIFECYCLE log level.

#### `TestLogging` `info`

Gets logging options for info level.

#### `TestLogging` `lifecycle`

Returns logging options for lifecycle level.

#### `int` `maxGranularity`

The maximum granularity of the events to be logged. Typically, 0 corresponds to the Gradle-generated test suite for the whole test run, 1 corresponds to the Gradle-generated test suite for a particular test JVM, 2 corresponds to a test class, and 3 corresponds to a test method. These values may extend higher if user-defined suites or parameterized test methods are executed. Events from levels higher than the specified granularity will be ignored.

The default granularity is -1, which specifies that test events from only the most granular level should be logged. Setting this value to something lower will cause events from a higher level to be ignored. For example, setting the value to 3 will cause only events from the test method level to be logged and any events from iterations of a parameterized test method will be ignored.

#### `int` `minGranularity`

The minimum granularity of the events to be logged. Typically, 0 corresponds to events from the Gradle-generated test suite for the whole test run, 1 corresponds to the Gradle-generated test suite for a particular test JVM, 2 corresponds to a test class, and 3 corresponds to a test method. These values may extend higher if user-defined suites or parameterized test methods are executed. Events from levels lower than the specified granularity will be ignored.

The default granularity is -1, which specifies that test events from only the most granular level should be logged. In other words, if a test method is not parameterized, only events from the test method will be logged and events from the test class and lower will be ignored. On the other hand, if a test method is parameterized, then events from the iterations of that test method will be logged and events from the test method and lower will be ignored.

#### `TestLogging` `quiet`

Returns logging options for quiet level.

#### `boolean` `showCauses`

Tells whether causes of exceptions that occur during test execution will be logged. Only relevant if `showExceptions` is `true`. Defaults to true.

#### `boolean` `showExceptions`

Tells whether exceptions that occur during test execution will be logged. Typically these exceptions coincide with a "failed" event. Defaults to true.

#### `boolean` `showStackTraces`

Tells whether stack traces of exceptions that occur during test execution will be logged. Defaults to true.

#### `boolean` `showStandardStreams`

Tells whether output on standard out and standard error will be logged. Equivalent to checking if both log events `TestLogEvent.STANDARD_OUT` and `TestLogEvent.STANDARD_ERROR` are set.

#### ``Set`<`TestStackTraceFilter`>` `stackTraceFilters`

The set of filters to be used for sanitizing test stack traces.

#### `TestLogging` `warn`

Gets logging options for warn level.