# How to display the order of task executing by 'println'?

**URL:** https://discuss.gradle.org/t/how-to-display-the-order-of-task-executing-by-println/45859
**Category:** Help/Discuss
**Created:** [June 19, 2023, 10:51am UTC](https://discuss.gradle.org/t/how-to-display-the-order-of-task-executing-by-println/45859 "2023-06-19T10:51:17Z")
**Posts on this page:** 19
**Page:** 1

<div class="post-metadata">

### Author: ![sclscldd](https://avatars.discourse-cdn.com/v4/letter/s/b5ac83/32.png) [@sclscldd](https://discuss.gradle.org/u/sclscldd)
#### Post date: [June 19, 2023, 10:51am UTC](https://discuss.gradle.org/t/how-to-display-the-order-of-task-executing-by-println/45859/1 "2023-06-19T10:51:17Z")

</div>

I’m using gradle-8.1.1-src and I wonder how to get the task name when touched in the executePlan.  
I know that the --profile command will generate a profile and show the task order, but I want to get the order in logging and compare them.  
Thanks for your help 🥲

---

<div class="post-metadata">

### Author: ![Vampire](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vampire/32/9082_2.png) [@Vampire](https://discuss.gradle.org/u/Vampire)
#### Post date: [June 19, 2023, 7:05pm UTC](https://discuss.gradle.org/t/how-to-display-the-order-of-task-executing-by-println/45859/2 "2023-06-19T19:05:15Z")

</div>

If you run with `--console=plain` or `--console=verbose` you should get all task names logged. It’s just the `rich` console that does not show task names unless there is some output except for in the progress message.

---

<div class="post-metadata">

### Author: ![sclscldd](https://avatars.discourse-cdn.com/v4/letter/s/b5ac83/32.png) [@sclscldd](https://discuss.gradle.org/u/sclscldd)
#### Post date: [June 20, 2023, 8:10am UTC](https://discuss.gradle.org/t/how-to-display-the-order-of-task-executing-by-println/45859/3 "2023-06-20T08:10:07Z")

</div>

OK, and I have an another problem that a project can be built by gradle-5.6.4, but when I use gradle-8.1.1, it will print wrong like:

> - Where:  
> Build file ‘/home/Apps/android-PictureInPicture-master/app/build.gradle’ line: 1

> - What went wrong:  
> A problem occurred evaluating project ‘:app’.  
> org/gradle/initialization/BuildCompletionListener

I wonder whether the new version can cover the old version

---

<div class="post-metadata">

### Author: ![Vampire](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vampire/32/9082_2.png) [@Vampire](https://discuss.gradle.org/u/Vampire)
#### Post date: [June 20, 2023, 9:00am UTC](https://discuss.gradle.org/t/how-to-display-the-order-of-task-executing-by-println/45859/4 "2023-06-20T09:00:49Z")

</div>

You cannot simply run a build designed for an old version with a new version.  
That is why each and every project even if tiny should include the 4 wrapper files.  
Those then define which Gradle version to use to execute the build and to execute the build you only need a compatible Java version, but never an installed Gradle version.

If you want to update the Gradle version, read the release notes and the upgrade notes which contain breaking changes. And then I usually recommend to update to the latest 5.x version, update all used plugins to the latest compatible version, then fix all deprecation warnings. If a build runs without deprecation warnings in the latest minor version, it should usually be compatible with the next minor version except for exceptions. So then update to the latest 6.x and repeat until you are at the target version.

---

<div class="post-metadata">

### Author: ![sclscldd](https://avatars.discourse-cdn.com/v4/letter/s/b5ac83/32.png) [@sclscldd](https://discuss.gradle.org/u/sclscldd)
#### Post date: [June 26, 2023, 7:58am UTC](https://discuss.gradle.org/t/how-to-display-the-order-of-task-executing-by-println/45859/5 "2023-06-26T07:58:44Z")

</div>

how to use the “log.info()” function, I see the method that use slf4j log.info() to print the message in log, but it shows the error:

 ![image](https://global.discourse-cdn.com/gradle/original/2X/d/d105a2778804850d621033830bc6ba9ae75e1f0d.png)  
so I’d like to know how to success.

---

<div class="post-metadata">

### Author: ![Vampire](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vampire/32/9082_2.png) [@Vampire](https://discuss.gradle.org/u/Vampire)
#### Post date: [June 26, 2023, 8:03am UTC](https://discuss.gradle.org/t/how-to-display-the-order-of-task-executing-by-println/45859/6 "2023-06-26T08:03:54Z")

</div>

Don’t try to use fields that do not exist?  
Did you ever program in Java before?  
`TaskExecution` has a `LOGGER` field with which you could log,  
`AbstractTask` has a `logger` field with which you could log.  
None of the two has a `log` field that you try to use and your error message is telling you that.

---

<div class="post-metadata">

### Author: ![sclscldd](https://avatars.discourse-cdn.com/v4/letter/s/b5ac83/32.png) [@sclscldd](https://discuss.gradle.org/u/sclscldd)
#### Post date: [June 26, 2023, 9:25am UTC](https://discuss.gradle.org/t/how-to-display-the-order-of-task-executing-by-println/45859/7 "2023-06-26T09:25:28Z")

</div>

ah sorry, I’m exactlly a rookie of Java. Now I add a “LOGGER.info(“here!!!”);” in TaskExecution.java, with function **executeAction()**, but when I run the command :

> **./gradlew assemble --no-configuration-cache**

there isn’t any “here!!!” appear in the log. So I’d like to know whether the gradle will touch the function **executeAction()** when executing tasks.

---

<div class="post-metadata">

### Author: ![Vampire](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vampire/32/9082_2.png) [@Vampire](https://discuss.gradle.org/u/Vampire)
#### Post date: [June 26, 2023, 10:33am UTC](https://discuss.gradle.org/t/how-to-display-the-order-of-task-executing-by-println/45859/8 "2023-06-26T10:33:14Z")

</div>

Info logs are only shown with `-i` / `--info` or higher.

---

<div class="post-metadata">

### Author: ![Vampire](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vampire/32/9082_2.png) [@Vampire](https://discuss.gradle.org/u/Vampire)
#### Post date: [June 26, 2023, 10:40am UTC](https://discuss.gradle.org/t/how-to-display-the-order-of-task-executing-by-println/45859/9 "2023-06-26T10:40:16Z")

</div>

Besides that a simple `tasks.configureEach { doFirst { logger.info("here!!!") } }` would probably be much easier than to compile a whole own Gradle distribution just to add that log line. 😃

---

<div class="post-metadata">

### Author: ![sclscldd](https://avatars.discourse-cdn.com/v4/letter/s/b5ac83/32.png) [@sclscldd](https://discuss.gradle.org/u/sclscldd)
#### Post date: [June 26, 2023, 10:42am UTC](https://discuss.gradle.org/t/how-to-display-the-order-of-task-executing-by-println/45859/10 "2023-06-26T10:42:46Z")

</div>

yeah, I get the log I want! Thank you for your helpful solution!

---

<div class="post-metadata">

### Author: ![sclscldd](https://avatars.discourse-cdn.com/v4/letter/s/b5ac83/32.png) [@sclscldd](https://discuss.gradle.org/u/sclscldd)
#### Post date: [June 27, 2023, 2:04am UTC](https://discuss.gradle.org/t/how-to-display-the-order-of-task-executing-by-println/45859/11 "2023-06-27T02:04:07Z")

</div>

And now another question is that I get the log text by `-i >1.txt` and the build report by `--profile`, with the num of `--max-workers` is 1, but the order of task executing is different. The order of log might be:

> Tasks to be executed: [task ‘:compileJava’, task ‘:processResources’, task ‘:classes’, task ‘:jar’, task ‘:assemble’, task ‘:generator:compileJava’, task ‘:generator:processResources’, task ‘:generator:classes’, task ‘:generator:jar’, task ‘:clients:processMessages’, task ‘:clients:compileJava’, task ‘:clients:processResources’,

And the order of report might be:

 ![image](https://global.discourse-cdn.com/gradle/original/2X/7/74f08e6a90777b12c6418721f2ccb642be37af54.png)

So,which is the actually executing order

---

<div class="post-metadata">

### Author: ![Vampire](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vampire/32/9082_2.png) [@Vampire](https://discuss.gradle.org/u/Vampire)
#### Post date: [June 27, 2023, 2:09am UTC](https://discuss.gradle.org/t/how-to-display-the-order-of-task-executing-by-println/45859/12 "2023-06-27T02:09:04Z")

</div>

Probably the second one.  
But I don’t know if that is guaranteed, never used `--profile`.  
If you want a representation where it is guaranteed, use a build `--scan`.

What do you actually try to achieve anyway?

---

<div class="post-metadata">

### Author: ![sclscldd](https://avatars.discourse-cdn.com/v4/letter/s/b5ac83/32.png) [@sclscldd](https://discuss.gradle.org/u/sclscldd)
#### Post date: [June 27, 2023, 2:23am UTC](https://discuss.gradle.org/t/how-to-display-the-order-of-task-executing-by-println/45859/13 "2023-06-27T02:23:51Z")

</div>

I just try to find the detailed location in source code that create the TaskGraph and put the tasks to execute one by one. If I could add something to print the TaskName with the same order of tasks actually executing, that means I find the method of how gradle dispatch the tasks, is it practicable?

---

<div class="post-metadata">

### Author: ![Vampire](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vampire/32/9082_2.png) [@Vampire](https://discuss.gradle.org/u/Vampire)
#### Post date: [June 27, 2023, 2:27am UTC](https://discuss.gradle.org/t/how-to-display-the-order-of-task-executing-by-println/45859/14 "2023-06-27T02:27:04Z")

</div>

What do you mean by “put the tasks to execute one by one.”?  
You want to make them not run in parallel?  
Why should you want to do that?  
And if so, why would `--max-workers 1` not be sufficient?

Again, what do you try to achieve?

---

<div class="post-metadata">

### Author: ![sclscldd](https://avatars.discourse-cdn.com/v4/letter/s/b5ac83/32.png) [@sclscldd](https://discuss.gradle.org/u/sclscldd)
#### Post date: [June 27, 2023, 2:32am UTC](https://discuss.gradle.org/t/how-to-display-the-order-of-task-executing-by-println/45859/15 "2023-06-27T02:32:01Z")

</div>

uh sorry I don’t express exactly, I’d like to find the detailed source code where the gradle get the tasks in TaskGraph and execute the tasks with the order managed by TaskGraph.

---

<div class="post-metadata">

### Author: ![Vampire](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vampire/32/9082_2.png) [@Vampire](https://discuss.gradle.org/u/Vampire)
#### Post date: [June 27, 2023, 12:40pm UTC](https://discuss.gradle.org/t/how-to-display-the-order-of-task-executing-by-println/45859/16 "2023-06-27T12:40:56Z")

</div>

But I suspect an XY problem. 🙂  
I’m still curious what you want to achieve in the end, i.e. why you search for that point in the code.

---

<div class="post-metadata">

### Author: ![sclscldd](https://avatars.discourse-cdn.com/v4/letter/s/b5ac83/32.png) [@sclscldd](https://discuss.gradle.org/u/sclscldd)
#### Post date: [June 28, 2023, 1:11am UTC](https://discuss.gradle.org/t/how-to-display-the-order-of-task-executing-by-println/45859/17 "2023-06-28T01:11:34Z")

</div>

Maybe compare gradle and makefile when they compile a project in parallel, what is the difference of dispatch method, and explore if there’s any optimization space 🥲

---

<div class="post-metadata">

### Author: ![Vampire](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vampire/32/9082_2.png) [@Vampire](https://discuss.gradle.org/u/Vampire)
#### Post date: [June 28, 2023, 1:15am UTC](https://discuss.gradle.org/t/how-to-display-the-order-of-task-executing-by-println/45859/18 "2023-06-28T01:15:07Z")

</div>

But why do you need that spot in the code for this?  
What do you want to achieve there?

---

<div class="post-metadata">

### Author: ![willow](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/willow/32/11083_2.png) [@willow](https://discuss.gradle.org/u/willow)
#### Post date: [June 15, 2024, 4:26pm UTC](https://discuss.gradle.org/t/how-to-display-the-order-of-task-executing-by-println/45859/19 "2024-06-15T16:26:55Z")

</div>

Hello,  
As per me to fetch the task name when executed in executePlan, you can log task order directly for comparison. This avoids relying solely on --profile, providing clear insights into task execution sequence and enabling effective build process optimization.  
Thanks
