Build a blog with Areto Node.js framework

Logging

The logger component provides logging for the Areto framework. It is created as an instance of the areto/log/Logger class.

Add the logger component in the application configuration.   Usually the logger is placed on the first place among the components.

config/default.js

module.exports = {
  ...
  components: {
    'logger': {
      level: 'info'
    }
    ...
  }
};

The level property contains the maximum level of stored logs.

Typical levels of logging: trace, debug, info, warning, error, fatal. Each level includes all the following ones. For example, if you set the info level, then the log will be kept with the following types: info, warning, error, fatal. And if you set the trace level, it will be stored in general, all the logs.

The optimal level for the development is trace. It is set in the config file development.

config/development.js

module.exports = {
  ...
  components: {
    'logger': {
      level: 'trace'
    }
    ...
  }
};

By default, the logs are stored as text files to the logs directory of the project root and are displayed in the server console. Log rotation occurs when the file size reaches the limit (default is 2 Mb).