What is Error Log and How to setup in MariaDB

Error Log

The error log contains a record of critical errors that occurred during the server's operation, table corruption, start and stop information.

If the log-warnings server system variable is 1 (default), critical SQL warnings will be logged in the error log. If its value is 0, the logging of SQL warnings is disabled. If its value is greater than 1, Statements that were unsafe to log as statement-based, aborted connections and access-denied errors for new connection attempts are also written to the error log. For a complete list, see the description of the log-warnings variable.

On Unix systems which support the logger program, errors can also be written into syslog. 

On Windows, the errors are also written in the Windows Event Log, in the Application Log. The source of the log enties is MySQL.

What is Statement based: The default format until MariaDB 10.2.3, statement-based logging logs all SQL statements that make changes to the data or structure of a table. Enable with --binlog-format=STATEMENT.

 The above definitions are taken from mariadb website. find the link here

Location of Error Log

Default: /var/lib/mysql/hostname.err

Current Error Log Location:
If you need to check the current location for your error log, you can use below statement.
MariaDB [(none)]>  SHOW VARIABLES LIKE 'log_error';


Check log_warraning value :
You can run below statement on mairadb to get current value for log_warrinings variable
MariaDB [(none)]>  SHOW VARIABLES LIKE 'log_warnings';

How to Enable: 

In case of Stand alone mairadb , go to /etc/my.cnf and make changes.
e.g
log-warnings=1
log-error=/DirectoryPath/ErrorLogFileName.log

In case of Galera cluster installation : Go to /etc/my.cnf.d/server.cnf
log-warnings=1
log-error=/DirectoryPath/ErrorLogFileName.log


Video Demo : What is Error Log in MariaDB and How to enable Error Logging in MariaDB