PHPackages                             parseword/logger - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. parseword/logger

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

parseword/logger
================

A PHP class implementing a text file logging facility

v1.0.2(7y ago)2281Apache-2.0PHPPHP &gt;=7.0

Since Jan 25Pushed 7y ago2 watchersCompare

[ Source](https://github.com/parseword/logger)[ Packagist](https://packagist.org/packages/parseword/logger)[ Docs](https://github.com/parseword/logger/)[ RSS](/packages/parseword-logger/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (2)DependenciesVersions (4)Used By (1)

Logger
======

[](#logger)

Logger is a PHP text file logging facility, implemented as a singleton. It's nothing special, but I'm breaking a larger code base down into independent components and I needed this to be in its own repository.

Usage
-----

[](#usage)

Implementing `Logger` in 4 easy steps:

1. Either `composer require parseword/logger` or copy the `Logger.php` file into your project.
2. Make sure `Logger.php` is discoverable by your autoloader, or `require_once`it manually.
3. Throughout your application code, call `Logger::debug()`, `Logger::info()`, `Logger::warning()` and `Logger::error()` to send log messages of differing severity levels.
4. In your application's config file or a common include file, you (or the user) call Logger::setFilename() to set the log file, and Logger::setSeverityFilter() to specify which log messages are written to disk.

Example
-------

[](#example)

In the following example, a file named `/tmp/my.log` is created. The severity filter is set so that only messages with severity of WARNING or higher will be written. Messages with lower severity will be disregarded.

```
