Where can I find the log files for scheduled cache cleanup

I have set the following options to regularly clear Gradle cache disk usage:

beforeSettings { 
     settings → settings.caches {
         createdResources.removeUnusedEntriesAfterDays = 1
         buildCache.removeUnusedEntriesAfterDays = 1
     }
}

Gradle Version: 8.9

May I ask where I can see the execution logs for this policy?

In <GRADLE_USER_HOME>/daemon/8.9/daemon-*.out.log.

Are there any specific tags or keywords that can be used to locate the relevant log entries?

“cleanup” case insensitively?

Or look for the lines after the line that starts with BUILD which is either BUILD FAILED or BUILD SUCCESSFUL. The cleanup happens after the actual build was finished.

We are performing builds on a CI server, and the build command specifies the --no-daemon parameter.

Doesn’t matter.
Nowadays --no-daemon usually means "use a one-off daemon that is only used for this build and then discarded.
So it really is --no-daemon-reuse most times.
To really have no daemon you would need to ensure the CLI process can serve as daemon process which would include setting the necessary heap options and also the Gradle instrumentation agent for the current Gradle version.

51179944        /.gradle/caches/build-cache-1
54743404        /.gradle/caches/8.9
4       /.gradle/caches/8.9/generated-gradle-jars
8       /.gradle/caches/8.9/file-changes
8       /.gradle/caches/8.9/md-rule
8       /.gradle/caches/8.9/md-supplier
20      /.gradle/caches/8.9/fileContent
85768   /.gradle/caches/8.9/fileHashes
181316  /.gradle/caches/8.9/groovy-dsl
1266880 /.gradle/caches/8.9/javaCompile
53209388        /.gradle/caches/8.9/transforms
54743404        /.gradle/caches/8.9

Our disk usage has reached 100G, and it seems that the configured strategy has not taken effect.

Build cache: The local build cache (e.g., build-cache-1).
The default retention period for unused build-cache entries is 7 days.

Can this be configured to automatically clear after 1 day? Which configuration option should be used?

current i set buildCache.removeUnusedEntriesAfterDays = 1

Sounds correct to me.
If it does not work in your setup, you should maybe report a bug. :man_shrugging:

Does this configuration require the number of days to be greater than 1? buildCache.removeUnusedEntriesAfterDays = 1

I have no idea, never used it.
If so, that’s a documentation bug and maybe also the call should fail.
The API you use does not specify that limitation. :man_shrugging:

Also, there is a test that you cannot set to <1: gradle/subprojects/core/src/test/groovy/org/gradle/api/internal/cache/DefaultCacheConfigurationsTest.groovy at master · gradle/gradle · GitHub

But no test that 1 does not work, so I would expect it to work.

And looking at gradle/subprojects/core-api/src/main/java/org/gradle/caching/local/DirectoryBuildCache.java at v8.14.3 · gradle/gradle · GitHub I’d say even in the old API 1 was ok but the JavaDoc was wrong.