9

A legacy application has 3000+ calls to System.out.

Using Intellij's refactoring tools, how can I (easily) replace calls to "System.out" with a calls to log4j/java.util.logging/etc?

I've poked around the refactoring menu but didn't see any options.

Note: I know i can use 'source code find/replace' , but was curious if the refactoring tools handled this type of usecase

thanks

user331465
  • 2,984
  • 13
  • 47
  • 77

2 Answers2

10

Use Structural Search and Replace

enter image description here

Meo
  • 12,020
  • 7
  • 45
  • 52
  • Perhaps it could be possible to also add a Logger field to classes which contain calls to System.out, so the code does not get broken... Any ideas? – Meo Jun 15 '15 at 22:25
0

to add a Logger to each Class you could use:

class $Class$ {
   $Content$
}


class $Class$ {
    private static org.apache.log4j.Logger log =  Logger.getLogger($Class$.class);
    $Content$
}
siser
  • 105
  • 1
  • 1
  • 5