Description

Logs messages to configured Log adapters. One or more adapters can be configured using uim Logs"s methods. If you don"t configure any adapters, and write to Log, the messages will be ignored. ### Configuring Log adapters You can configure log adapters in your applications `config/app.d` file. A sample configuration would look like: ``` Log.configuration.set("_log", ["classname": "FileLog"]); ``` You can define the classname as any fully namespaced classname or use a short hand classname to use loggers in the `App\Log\Engine` & `UIM\Log\Engine` namespaces. You can also use plugin short hand to use logging classes provided by plugins. Log adapters are required to implement `Psr\Log\ILogger`, and there is a built-in base class (`UIM\Log\Engine\BaseLog`) that can be used for custom loggers. Outside of the `classname` key, all other configuration values will be passed to the logging adapter"s constructor as an array. ### Logging levels When configuring loggers, you can set which levels a logger will handle. This allows you to disable debug messages in production for example: ``` Log.configuration.set("default", [ "classname": "File", "path": LOGS, "levels": ["error", "critical", "alert", "emergency"] ]); ``` The above logger would only log error messages or higher. Any other log messages would be discarded. ### Logging scopes When configuring loggers you can define the active scopes the logger is for. If defined, only the listed scopes will be handled by the logger. If you don"t define any scopes an adapter will catch all scopes that match the handled levels. ``` Log.configuration.set("payments", [ "classname": "File", "scopes": ["payment", "order"] ]); ``` The above logger will only capture log entries made in the `payment` and `order` scopes. All other scopes including the undefined scope will be ignored. ### Writing to the log You write to the logs using Log.write(). See its documentation for more information. ### Logging Levels By default uim Log supports all the log levels defined in RFC 5424. When logging messages you can either use the named methods, or the correct constants with `write()`: ``` Log.error("Something horrible happened"); Log.write(LOGS.ERROR, "Something horrible happened"); ``` ### Logging scopes When logging messages and configuring log adapters, you can specify "scopes" that the logger will handle. You can think of scopes as subsystems in your application that may require different logging setups. For example in an e-commerce application you may want to handle logged errors in the cart and ordering subsystems differently than the rest of the application. By using scopes you can control logging for each part of your application and also use standard log levels.

Properties