Show Eclipse IDE’s Java Console Log in VS-Code

This is a step-to-step instruction on how to display Eclipse IDE’s console output in VS-Code’s terminal view.

Table of Contents

    Introduction

    It’s a little bit of a strange setup, but that’s how I’m working in a project right now: I have an API (Java App) running in Debug mode in Eclipse IDE. The frontend on the other hand is written using a JavaScript Framework. I personally prefer to code JavaScript/TypeScript in VS-Code.

    Since the API is almost finished I almost always have my Eclipse IDE minimized to the tray-bar of my Desktop-Environment. The problem is, that I can’t see the Debug-Output of my API.

    To circumvent this inconvenience I looked for a way to follow Eclipse’s Debug output in VS-Code. The solution is quite easy.

    This tutorial shows each step for Windows OS, but this also works in MacOS or any Linux flavour (Ubuntu, Debian, Fedora etc.)

    Redirect Console log to file in Eclipse

    Eclipse allows you to redirect all console output to a file on your filesystem.

    Just follow the following steps in Eclipse IDE:

    1. Open from the menu “Run -> Run configurations…” or “Run -> Debug configurations…“.
    2. Select the project on the tree (left)
    3. change to tab “Common
    4. activate the checkbox “Output file
    5. Choose a desired target-folder an filename (in my cast “C:\temp\k10_eclipse.log”)
    6. If you activate the checkbox “Append” eclipse won’t flush the file’s content after each start (watch out: files might get big)

    That’s it. Now you have Eclipse IDE set-up to log all console-output into a file.

    Open the Run Configuration in Eclipse IDE
    Redirect Console output to file in Eclipse IDE

    Show File content in VS Code

    You can use the shell commands “tail” (Bash, Git-Bash etc.) or “Get-Content” (Windows Power-Shell) to follow the file. This method is not restricted to VS-Code. You can use any Shell on any OS to follow the content of the file.

    Show content of file in VS-Code’s Terminal View

    Power-Shell

    In VS-Code open the Terminal-View with “View -> Open View -> Terminal”. Enter the following command to see and follow the content of the file:

    cd C:\temp\
    Get-Content -Path "C:\temp\k10_eclipse.log" -Wait

    Bash or Git-Bash

    If you’re using windows Git-Bash must be installed.

    In VS-Code open the Terminal-View with “View -> Open View -> Terminal”. Enter the following command to see and follow the content of the file:

    cd /c/temp/
    tail -fn 100 /c/temp/k10_eclipse.log

    Your opinion

    Let me know waht you think about this tutorial. Leave a comment below.

    Georg Abenthung

    Working in IT since 2004.

    Leave a Reply

    Your email address will not be published. Required fields are marked *