...

/

Logging Information I

Logging Information I

Let’s learn how to log information using the log.Fatal() and log.Panic() functions.

Although it is useful to print error messages onscreen, there are times that we need to keep all error messages together and be able to search them when it is convenient for us. In this case, we need to use one or more log files.

Introduction to logging information

Log files

All UNIX systems have their own log files for writing logging information that comes from running servers and programs. Usually, most system log files of a UNIX system can be found under the /var/log directory. However, the log files of many popular services, such as Apache and Nginx, can be found elsewhere, depending on their configuration.

Generally speaking, using a log file to write some information used to be considered a better practice than writing the same output on the screen for two reasons: firstly, because the output does not get lost as it is stored on a file, and secondly, because we can search and process log files using UNIX tools, such as ...