How to make vscode terminal window clear previous spring boot output automatically

javavisual-studio-code

I've managed to setup VS Code on my win10 with Extension Pack for Java and
Code Runner I also enabled "clear previous output"

enter image description here

each time I right click and "Run Java",

enter image description here

VS code dump the output on the terminal window cumulatively.

enter image description here

the red rectangle indicates the first output and the blue the 2nd.

which means vscode doesn't clear the output before new run, and then I tried another option

enter image description here

which works for the simple pojo project.

However, when I run the spring boot project, the terminal window keeps part of the logging anyway,

enter image description here

how do I make vscode clear all the previous spring boot output automatically as it does for pojo projects?

PS:

I also tried this task config which doesn't work either.

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "java",
            "mainClass": "com.example.mongo.MongoApplication",
            "targetPath": "${workspaceFolder}/${workspaceFolderBasename}.jar",
            "elements": [
                "${compileOutput}",
                "${dependencies}"
            ],
            "problemMatcher": [],
            "label": "java: exportjar:mongo",
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "presentation": {
                "clear": true // <-- this line
            }
        }
    ]
}

enter image description here

Best Answer

A possible solution, published recently on Stack Overflow, is to modify settings.json so it looks like this:

{
    "editor.fontSize": 17,
    "code-runner.runInTerminal": true,
    "terminal.integrated.profiles.windows": {
        "PowerShell": {
            "source": "PowerShell",
        "args": ["-noLogo"]
        }
    },
    "terminal.integrated.defaultProfile.windows": "PowerShell"
}

If this doesn't work either (in addition to the other suggestions below the post), then the basic problem is that "code-runner.clearPreviousOutput": true works well in the OUTPUT panel, but does not work in the terminal.

A feature request was submitted for it at : Add code-runner.clearPrevious for terminal tab #832. You may upvote it, which is basically your last option.

Related Question