The logger gives you the ability to define different levels of importance of the logged messages and the ability to use different sink for the output - the console, a file, etc.
Also it's easy to enable or disable only some type of message when using a logger - for example you don't want to see every debug message in production.
We can also use logger for profiling i.e; it can become a good tool to profile sections of a program, for instance by logging the start and end of an operation.
Creating a good log file: