Download the PHP package xp-framework/logging without Composer
On this page you can find all versions of the php package xp-framework/logging. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download xp-framework/logging
More information about xp-framework/logging
Files in xp-framework/logging
Package logging
Short Description Logging for the XP Framework
License BSD-3-Clause
Homepage http://xp-framework.net/
Informations about the package logging
Logging
Logging for the XP Framework.
Example
Levels
This library supports the following levels: DEBUG, INFO, WARN and ERROR. As seen above, messages can be logged using methods named after these levels. All methods have a printf-style variant:
debug(var... $args)
anddebugf(string $format, var... $args)
.info(var... $args)
andinfof(string $format, var... $args)
.warn(var... $args)
andwarnf(string $format, var... $args)
.error(var... $args)
anderrorf(string $format, var... $args)
.
Appenders
The following appenders are available:
util.log.FileAppender(string $filename)
- Logs to a local fileutil.log.ConsoleAppender()
- Logs to consoleutil.log.ColoredConsoleAppender()
- Logs to console using colors depending on log levelutil.log.SmtpAppender(string $email, string $prefix= "", bool $sync= true)
- Logs by email to a given email addressutil.log.StreamAppender(io.streams.OutputStream $out)
- Logs to any output stream fromio.streams
.util.log.SyslogAppender(string $identifier, int $facility= LOG_USER)
- Logs using syslog facilityutil.log.SyslogUdpAppender(string $ip= '127.0.0.1', int $port= 514, string $identifier= null, int $facility= LOG_USER, string $hostname= null)
- Logs using syslog protocol over UDPutil.log.BufferedAppender()
- Logs to a memory buffer
Layout
The default log layout includes time, pid, level and message implemented by the util.log.layout.DefaultLayout
class. It renders as follows:
The log layout can be changed by instantiating the util.log.layout.PatternLayout
, passing a format string and using the appenders setLayout()
method to use it. The format string consists of format tokens preceded by a percent sign (%) and any other character. The following format tokens are
supported:
%m
- Message%c
- Category name%l
- Log level - lowercase%L
- Log level - uppercase%d
- Date in YYYY-MM-DD%t
- Time in HH:MM:SS%p
- Process ID%%
- A literal percent sign (%)%n
- A line break%x
- Context information, if available
Configuration
Instead of using the Logging DSL to create your log setup programmatically, you can use the configuration API, which works with INI files:
Further reading
All versions of logging with dependencies
xp-framework/reflection Version ^3.0 | ^2.0
php Version >=7.0.0