0

I saw in the stack overflow when it comes to server side industrial level applications using a logger framework over System.out.println() is an efficient way to deal with Logging.And I also red that System.out.println() is an I/O operation,because of that it needs more CPU usage.So I need to know is logger.info() [which is a builtin class comes with java] is an I/O operation or not and a explanation why if it is not.

  • Ultimately, there will be IO, but IO in logging frameworks are usually more optimized for throughput (and a broad range of targets, eg logging into a remote logging platform, etc) compared to `System.out.println`. – Mark Rotteveel Jan 16 '20 at 08:55

1 Answers1

1

It depends on the registered handler(s).

By default, JUL outputs to console via a ConsoleHandler, that is an IO operation. If logging is configured with a handler that logs to file (FileHandler) or via Network (SocketHandler), that would also be an IO operation.

There is also a MemoryHandler, which wouldn't make logging an IO operation. But it has a very, very limited usefulness.

Using another log framework like SLF4J doesn't change that. Logging is inherently an IO operation, since you want the log to be accessible outside of the application and even after the termination of the process. It is still advantageous to use a framework like SLF4J, though, for various reasons (cf. Why not use java.util.logging?).

Polygnome
  • 7,639
  • 2
  • 37
  • 57