Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Legacy Java code refactoringNew to Visual Studio Code? Get it now.
Legacy Java code refactoring

Legacy Java code refactoring

Jan Dolejsi

|
546 installs
| (0) | Free
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Legacy Java Code Refactoring extension for VS Code

CI/CD

System.out|err -> logger.info|debug|trace|error

If you place your cursor on a line containing a System.out or System.err calls, a code action will be proposed to convert them to a logger call while refactoring the argument.

For example, with a single click, you can convert this line:

System.out.println("Var1=" + var1 + ", var2=" + var2);

...to...

logger.info("Var1={}, var2={}", var1, var2);

... which allows flexibly setting the verbosity level using post-deployment configuration, while diagnosing runtime issues.

Doing this manually is a tedious and error prone process.

System.out refactoring

Pre-requisites

You will need to add imports to your Java class:

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

You will need the static declaration of the logger field inside the class:

private static final Logger logger = LoggerFactory.getLogger(YourClass.class);

You will also need to add the dependency on the package. See https://www.slf4j.org/manual.html for more info.

Alternatively, you may just decorate your class with @Slf4j attribute, if you also use lombok.

Known issues

The extension does not handle System.out calls with multiple arguments that already use %s and other macros.

Line and block comments inside the System.out method call may also not be handled correctly.

Development

Code actions are used to implement quick fixes and refactoring in VS Code. We use CodeActionProvider api to implement a small set of refactoring that occur chronically in code written by our dear colleague DL.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft