0

I have a Java project where I'm using multiple .jar files, and multiple classes. The project itself runs with the desired output - that's not where the issue lies.It uses Java, JSON, external API and local host.

Midway through running the program, the console prints the following (see attached image):

enter image description here

Is there anyway to prevent this from happening, and to perhaps silence it from showing as output? It obviously doesn't look very appealing when using the program!

Many thanks!

James
  • 91
  • 1
  • 2
  • 10

2 Answers2

1

Thanks to @Deadpool for this suggestion - I'm not sure if this is exactly what was suggested, but it works for me.

In the main .java file, I added:

    import java.util.logging.Level;
    import java.util.logging.Logger;

and then at the top of my main, I added:

    Logger.getLogger("").setLevel(Level.SEVERE);

There is probably a more specific approach to this (i.e. not just getting every logger), but I thought I would post what works in case anyone else comes across this who is desperate for an answer!

James
  • 91
  • 1
  • 2
  • 10
0

James, what you have implemented is the highest order of fatality in logging and what Deadpool suggested is the second level.

Different log level are described here: When to use the different log levels

If you want to switch this off completely in all scenarios,

Logger.getRootLogger("").setLevel(Level.OFF);
Abhishek
  • 5
  • 6