Download the PHP package mimmi20/monolog-factory without Composer
On this page you can find all versions of the php package mimmi20/monolog-factory. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mimmi20/monolog-factory
More information about mimmi20/monolog-factory
Files in mimmi20/monolog-factory
Package monolog-factory
Short Description Provides a Factory to build a Monolog Logger.
License MIT
Homepage https://github.com/mimmi20/monolog-factory
Informations about the package monolog-factory
monolog-factory
Monolog Factories for Laminas and Mezzio
This library was inspired by psr11-monolog and monolog-factory.
Code Status
Table of Contents
- Installation
- Usage with Laminas and Mezzio
- Configuration
- Minimal Configuration
- Full Configuration
- Handlers
- Log to files and syslog
- StreamHandler
- RotatingFileHandler
- SyslogHandler
- ErrorLogHandler
- ProcessHandler
- Send alerts and emails
- NativeMailerHandler
- SymfonyMailerHandler
- PushoverHandler
- FlowdockHandler
- SlackWebhookHandler
- SlackHandler
- SendGridHandler
- MandrillHandler
- FleepHookHandler
- IFTTTHandler
- TelegramBotHandler
- Log specific servers and networked logging
- SocketHandler
- AmqpHandler
- GelfHandler
- ZendMonitorHandler
- NewRelicHandler
- LogglyHandler
- RollbarHandler
- SyslogUdpHandler
- LogEntriesHandler
- InsightOpsHandler
- LogmaticHandler
- SqsHandler
- Logging in development
- FirePHPHandler
- ChromePHPHandler
- BrowserConsoleHandler
- Log to databases
- RedisHandler
- RedisPubSubHandler
- MongoDBHandler
- CouchDBHandler
- DoctrineCouchDBHandler
- ElasticaHandler
- ElasticsearchHandler
- DynamoDbHandler
- Wrappers / Special Handlers
- FingersCrossedHandler
- DeduplicationHandler
- WhatFailureGroupHandler
- FallbackGroupHandler
- BufferHandler
- GroupHandler
- FilterHandler
- SamplingHandler
- NoopHandler
- NullHandler
- PsrHandler
- TestHandler
- OverflowHandler
- 3rd Party Handlers
- MicrosoftTeamsHandler
- TeamsLogHandler
- CallbackFilterHandler
- Formatters
- LineFomatter
- HtmlFormatter
- NormalizerFormatter
- ScalarFormatter
- JsonFormatter
- WildfireFormatter
- ChromePHPFormatter
- GelfMessageFormatter
- LogstashFormatter
- ElasticaFormatter
- ElasticsearchFormatter
- LogglyFormatter
- FlowdockFormatter
- MongoDBFormatter
- LogmaticFormatter
- FluentdFormatter
- StreamFormatter
- Processors
- PsrLogMessageProcessor
- IntrospectionProcessor
- WebProcessor
- MemoryUsageProcessor
- MemoryPeakUsageProcessor
- ProcessIdProcessor
- UidProcessor
- GitProcessor
- MercurialProcessor
- TagProcessor
- HostnameProcessor
Installation
Run
Usage with Laminas and Mezzio
You'll need to add configuration and register the services you'd like to use. There are number of ways to do that
but the recommended way is to create a new config file config/autoload/logger.config.php
Configuration
config/autoload/logger.config.php
Minimal Configuration
A minimal configuration would consist of at least one default handler and one named service. Please note that if you don't specify a default handler a NullHandler will be used when you wire up the default logger.
Minimal Example (using Mezzio for the example)
Full Configuration
Full Example
Handlers
Log to files and syslog
StreamHandler
Logs records into any PHP stream, use this for log files.
Monolog Docs: StreamHandler
RotatingFileHandler
Logs records to a file and creates one logfile per day. It will also delete files older than $maxFiles. You should use [logrotate] for high profile setups though, this is just meant as a quick and dirty solution.
Monolog Docs: RotatingFileHandler
SyslogHandler
Logs records to the syslog.
Monolog Docs: SyslogHandler PHP openlog(): openlog
ErrorLogHandler
Logs records to PHP's error_log() function.
Monolog Docs: ErrorLogHandler
ProcessHandler
Logs records to the STDIN of any process, specified by a command.
Monolog Docs: ProcessHandler
Send alerts and emails
NativeMailerHandler
Sends emails using PHP's mail() function.
Monolog Docs: NativeMailerHandler
SymfonyMailerHandler
Sends emails using a symfony/mailer instance.
Monolog Docs: SymfonyMailerHandler
PushoverHandler
Sends mobile notifications via the Pushover API. Requires the sockets Extension.
Monolog Docs: PushoverHandler
FlowdockHandler
Logs records to a Flowdock account. Requires the openssl and sockets Extensions.
Monolog Docs: FlowdockHandler
SlackWebhookHandler
Logs records to a Slack account using Slack Webhooks. Requires the curl Excension.
Monolog Docs: SlackWebhookHandler
SlackHandler
Logs records to a SlackHandler account using the Slack API (complex setup). Requires the openssl and sockets Extensions.
Monolog Docs: SlackHandler
SendGridHandler
Sends emails via the SendGrid API. Requires the curl Excension.
Monolog Docs: SendGridHandler
MandrillHandler
Sends emails via the Mandrill API using a Swift_Message instance. Requires the curl Excension.
Monolog Docs: MandrillHandler
FleepHookHandler
Logs records to a Fleep conversation using Webhooks. Requires the openssl and sockets Extensions.
Monolog Docs: FleepHookHandler
IFTTTHandler
IFTTTHandler uses cURL to trigger IFTTT Maker actions. Requires the curl Extensions.
Monolog Docs: IFTTTHandler
TelegramBotHandler
Logs records to a Telegram bot account. Requires the curl Excension.
Monolog Docs: TelegramBotHandler
Log specific servers and networked logging
SocketHandler
Logs records to sockets, use this for UNIX and TCP sockets. See an example. Requires the sockets Extension.
Monolog Docs: SocketHandler
AmqpHandler
Logs records to an AMQP compatible server. Requires the php-amqp extension (1.0+) or the php-amqplib library.
Monolog Docs: AmqpHandler
GelfHandler
Logs records to a Graylog server. Requires package graylog2/gelf-php.
Monolog Docs: GelfHandler
ZendMonitorHandler
Logs records to the Zend Monitor present in Zend Server.
Monolog Docs: ZendMonitorHandler
NewRelicHandler
Logs records to a NewRelic application. Requires the newrelic Extension.
Monolog Docs: NewRelicHandler
LogglyHandler
Logs records to a Loggly account. Requires the curl Excension.
Monolog Docs: LogglyHandler
RollbarHandler
Logs records to a Rollbar account.
_Note: RollerbarHandler is out of date with upstream changes. In addition the Rollerbar library suggests using the PsrHandler instead. See Rollerbar Docs for how to set this up.
Monolog Docs: RollbarHandler
SyslogUdpHandler
Logs records to a remote Syslogd server. Requires the sockets Extension.
Monolog Docs: SyslogUdpHandler
LogEntriesHandler
Logs records to a LogEntries account. Requires the openssl and sockets Extensions.
Monolog Docs: LogEntriesHandler
InsightOpsHandler
Logs records to an InsightOps account. Requires the openssl and sockets Extensions.
Monolog Docs: InsightOpsHandler
LogmaticHandler
Logs records to a Logmatic account. Requires the openssl and sockets Extensions.
Monolog Docs: LogmaticHandler
SqsHandler
Logs records to an AWS SQS queue.
Monolog Docs: SqsHandler
Logging in Development
FirePHPHandler
Handler for FirePHP, providing inline console messages within FireBug.
Note: The Firebug extension isn't being developed or maintained any longer.
Monolog Docs: FirePHPHandler
ChromePHPHandler
Handler for ChromePHP, providing inline console messages within Chrome. Requires the json Extension.
Monolog Docs: ChromePHPHandler
BrowserConsoleHandler
Handler to send logs to browser's Javascript console with no browser extension required. Most browsers supporting console API are supported.
Monolog Docs: BrowserConsoleHandler
Log to databases
RedisHandler
Logs records to a Redis server. Requires the php-redis extension or the Predis library.
Monolog Docs: RedisHandler
RedisPubSubHandler
Logs records to a Redis server. Requires the php-redis extension or the Predis library.
Monolog Docs: RedisPubSubHandler
MongoDBHandler
Handler to write records in MongoDB via a Mongo extension connection.
Monolog Docs: MongoDBHandler
CouchDBHandler
Logs records to a CouchDB server.
Monolog Docs: CouchDBHandler
DoctrineCouchDBHandler
Logs records to a CouchDB server via the Doctrine CouchDB ODM.
Monolog Docs: DoctrineCouchDBHandler
ElasticaHandler
Logs records to an Elastic Search server. Requires Elastica.
Note: The version of the client should match the server version, but there is actually no 8.x version.
Monolog Docs: ElasticaHandler
ElasticsearchHandler
Logs records to an Elastic Search server. Requires the Elasticsearch PHP client.
Note: The version of the client should match the server version.
Monolog Docs: ElasticsearchHandler
DynamoDbHandler
Logs records to a DynamoDB table with the AWS SDK.
Monolog Docs: DynamoDbHandler
Wrappers / Special Handlers
FingersCrossedHandler
A very interesting wrapper. It takes a logger as parameter and will accumulate log records of all levels until a record exceeds the defined severity level. At which point it delivers all records, including those of lower severity, to the handler it wraps. This means that until an error actually happens you will not see anything in your logs, but when it happens you will have the full information, including debug and info records. This provides you with all the information you need, but only when you need it.
Monolog Docs: FingersCrossedHandler
DeduplicationHandler
Useful if you are sending notifications or emails when critical errors occur. It takes a logger as parameter and will accumulate log records of all levels until the end of the request (or flush() is called). At that point it delivers all records to the handler it wraps, but only if the records are unique over a given time period (60 seconds by default). If the records are duplicates they are simply discarded. The main use of this is in case of critical failure like if your database is unreachable for example all your requests will fail and that can result in a lot of notifications being sent. Adding this handler reduces the amount of notifications to a manageable level.
Monolog Docs: DeduplicationHandler
WhatFailureGroupHandler
This handler extends the GroupHandler ignoring exceptions raised by each child handler. This allows you to ignore issues where a remote tcp connection may have died but you do not want your entire application to crash and may wish to continue to log to other handlers.
Monolog Docs: WhatFailureGroupHandler
FallbackGroupHandler
This handler extends the GroupHandler ignoring exceptions raised by each child handler, until one has handled without throwing. This allows you to ignore issues where a remote tcp connection may have died but you do not want your entire application to crash and may wish to continue to attempt log to other handlers, until one does not throw.
Monolog Docs: FallbackGroupHandler
BufferHandler
This handler will buffer all the log records it receives until close() is called at which point it will call handleBatch() on the handler it wraps with all the log messages at once. This is very useful to send an email with all records at once for example instead of having one mail for every log record.
Monolog Docs: BufferHandler
GroupHandler
This handler groups other handlers. Every record received is sent to all the handlers it is configured with.
Monolog Docs: GroupHandler
FilterHandler
Simple handler wrapper that filters records based on a list of levels
Monolog Docs: FilterHandler
SamplingHandler
A sampled event stream can be useful for logging high frequency events in a production environment where you only need an idea of what is happening and are not concerned with capturing every occurrence. Since the decision to handle or not handle a particular event is determined randomly, the resulting sampled log is not guaranteed to contain 1/N of the events that occurred in the application, but based on the Law of large numbers, it will tend to be close to this ratio with a large number of attempts.
Monolog Docs: SamplingHandler
NoopHandler
This handler handles anything by doing nothing. It does not stop processing the rest of the stack. This can be used for testing, or to disable a handler when overriding a configuration.
Monolog Docs: NoopHandler
NullHandler
Any record it can handle will be thrown away. This can be used to put on top of an existing stack to override it temporarily.
Monolog Docs: NullHandler
PsrHandler
Can be used to forward log records to an existing PSR-3 logger
Monolog Docs: PsrHandler
TestHandler
Used for testing, it records everything that is sent to it and has accessors to read out the information.
Monolog Docs: TestHandler
OverflowHandler
This handler will buffer all the log messages it receives, up until a configured threshold of number of messages of a certain lever is reached, after it will pass all log messages to the wrapped handler. Useful for applying in batch processing when you're only interested in significant failures instead of minor, single erroneous events.
Monolog Docs: OverflowHandler
3rd Party Handlers
MicrosoftTeamsHandler
Sends Records to a Microsoft Teams Webhook. Requires package actived/microsoft-teams-notifier
TeamsLogHandler
Sends Records to a Microsoft Teams Webhook. Requires package cmdisp/monolog-microsoft-teams
CallbackFilterHandler
Filters Records with a Callback function. Requires bartlett/monolog-callbackfilterhandler
Formatters
LineFomatter
Formats a log record into a one-line string.
Monolog Docs: LineFormatter
HtmlFormatter
Used to format log records into a human readable html table, mainly suitable for emails.
Monolog Docs: HtmlFormatter
NormalizerFormatter
Normalizes objects/resources down to strings so a record can easily be serialized/encoded. Requires the json Extension.
Monolog Docs: NormalizerFormatter
ScalarFormatter
Used to format log records into an associative array of scalar values.
Monolog Docs: ScalarFormatter
JsonFormatter
Encodes a log record into json.
Monolog Docs: JsonFormatter
WildfireFormatter
Used to format log records into the Wildfire/FirePHP protocol, only useful for the FirePHPHandler.
Monolog Docs: WildfireFormatter
ChromePHPFormatter
Used to format log records into the ChromePHP format, only useful for the ChromePHPHandler.
Monolog Docs: ChromePHPFormatter
GelfMessageFormatter
Used to format log records into Gelf message instances, only useful for the GelfHandler.
Monolog Docs: GelfMessageFormatter
LogstashFormatter
Used to format log records into logstash event json, useful for any handler listed under inputs here.
Monolog Docs: LogstashFormatter
ElasticaFormatter
Used to format log records into an Elastica Document.
Monolog Docs: ElasticaFormatter
ElasticsearchFormatter
Used to format log records into an Elasticsearch Document.
Monolog Docs: ElasticsearchFormatter
LogglyFormatter
Used to format log records into Loggly messages, only useful for the LogglyHandler.
Monolog Docs: LogglyFormatter
FlowdockFormatter
Used to format log records into Flowdock messages, only useful for the FlowdockHandler.
Monolog Docs: FlowdockFormatter
MongoDBFormatter
Converts \DateTime instances to \MongoDate and objects recursively to arrays, only useful with the MongoDBHandler.
Monolog Docs: MongoDBFormatter
LogmaticFormatter
User to format log records to Logmatic messages, only useful for the LogmaticHandler.
Monolog Docs: LogmaticFormatter
FluentdFormatter
Serializes a log message to Fluentd unix socket protocol. Requires the json Extension.
Monolog Docs: FluentdFormatter
StreamFormatter
Formats the message using a symfony table. Requires StreamFormatter.
Processors
PsrLogMessageProcessor
Processes a log record's message according to PSR-3 rules, replacing {foo} with the value from $context['foo'].
Monolog Docs: PsrLogMessageProcessor
IntrospectionProcessor
Adds the line/file/class/method from which the log call originated.
Monolog Docs: IntrospectionProcessor
WebProcessor
Adds the current request URI, request method and client IP to a log record.
Monolog Docs: WebProcessor
MemoryUsageProcessor
Adds the current memory usage to a log record.
Monolog Docs: MemoryUsageProcessor
MemoryPeakUsageProcessor
Adds the peak memory usage to a log record.
Monolog Docs: MemoryPeakUsageProcessor
ProcessIdProcessor
Adds the process id to a log record.
Monolog Docs: ProcessIdProcessor
UidProcessor
Adds a unique identifier to a log record.
Monolog Docs: UidProcessor
GitProcessor
Adds the current git branch and commit to a log record.
Note: Only works if the git executable is in your working path.
Monolog Docs: GitProcessor
MercurialProcessor
Adds the current hg branch and commit to a log record.
Note: Only works if the hg executable is in your working path.
Monolog Docs: MercurialProcessor
TagProcessor
Adds an array of predefined tags to a log record.
Monolog Docs: TagProcessor
HostnameProcessor
Adds the current hostname to a log record.
Monolog Docs: HostnameProcessor
RequestHeaderProcessor
Adds Request Headers to a log record. Requires jk/monolog-request-header-processor
License
This package is licensed using the MIT License.
Please have a look at LICENSE.md
.
All versions of monolog-factory with dependencies
ext-mbstring Version *
monolog/monolog Version ^3.8.1
psr/container Version ^1.1.2 || ^2.0.2
psr/log Version ^3.0.0