1

I'm using Java with Spring Boot in IntelliJ Community edition. I usually use console.log() in the front-end to debug my code and see the value of a variable. Here in the back-end I try to do the same using System.out.println. For example

System.out.println("page is" + query.page());
return dslContext.select(...

I'm looking at the IntelliJ terminal but not getting anything back there.

Hanna
  • 539
  • 2
  • 9
  • 24

1 Answers1

3

You can use the logger from java.util.logging.Logger

    private static final long serialVersionUID=1L;
    public static Logger logger=Logger.getLogger("global");
    //do some
    logger.info("page is"+query.page());
xtratic
  • 4,600
  • 2
  • 14
  • 32
  • Where should I add these lines? `Cannot resolve symbol Logger` – Hanna Nov 30 '18 at 16:46
  • 1
    This after the class declaration `private static final long serialVersionUID=1L;` after add this `public static Logger logger=Logger.getLogger("global");` and when you need to use logger you do `logger.info("page is"+query.page())`; – Francesco Vicidomini Nov 30 '18 at 16:49
  • needed to import `import java.util.logging.Logger;` and still can't see any result in the terminal – Hanna Nov 30 '18 at 17:03
  • 2
    The logger output might go to a file, depending on configuration. Still a mystery why System.out.println didn't work – DodgyCodeException Nov 30 '18 at 17:09
  • 1
    This doesn't actually answer why `System.out.println` didn't work, even if using a logging framework is better practice – Krease Nov 30 '18 at 18:06