Custom Logger buildStarted not being called


(Michael Irby II) #1

I am using a custom logger with useLogger() in my init.gradle script. The logger extends the BuildAdapter and implements the TaskExectutionListener. I am overriding the buildStarted method, but it is never actually called. Is this the correct method to override to get the notification when the build started?


(Peter Niederwieser) #2

The earliest possible time you can log something is right in ‘init.gradle’, by which time the build has already started. Since user code can only register a logger after the build has started, the ‘buildStarted’ method won’t be called anymore.


(Benjamin Muschko) #3

This question was asked before: When is Gradle.buildStarted called?


(Michael Irby II) #4

Yes, my main exercise to be able to calculate a build time using the logger class. Since when you take over the logger you lose the elapsed time of the build at the end. Is there any other simple way to calculate the build time since a user will never actually know when the build started? Or would it be enough to just calculate the time each task takes to complete and use that. Although task execution is not part of configuration.


(Peter Niederwieser) #5

You can approximate build start time with the time your init code runs.


(Michael Irby II) #6

ok, thanks. that works.