If you intend to stop logging, you can disable logging using Logger#setLevel(Level.OFF) (assuming you are using a standard logger). If you intend to reduce the number of text messages, you can use Level.WARNING, for example, for which only WARNING and SEVERE messages are logged. As a rule, you can set a minimum level for entering any level. When your application starts without a console, Console usually not tied to it (but I think this is a platform problem, for example, some platforms can provide center consoles, which, it seems to me, while Java web applications work in servlet containers , even if the container was launched from the console, as a rule, it is not connected to the console), so I will not argue with my code for any reason. If you still want your logs in an application that did not have a Console attached at run time, you can always redirect your log messages to a file using Logger#addHandler(FileHandler) .
source share