PHPackages                             llagerlof/mylogphp - 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. llagerlof/mylogphp

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

llagerlof/mylogphp
==================

MyLogPHP is a single PHP class to easily keep log files in CSV format.

293.6k5[1 issues](https://github.com/llagerlof/MyLogPHP/issues)1PHP

Since Apr 1Pushed 5y ago4 watchersCompare

[ Source](https://github.com/llagerlof/MyLogPHP)[ Packagist](https://packagist.org/packages/llagerlof/mylogphp)[ RSS](/packages/llagerlof-mylogphp/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (1)

MyLogPHP
========

[](#mylogphp)

MyLogPHP is a single PHP class to easily keep log files in CSV format.

Install the latest version
--------------------------

[](#install-the-latest-version)

### Direct download (just include this file in your script)

[](#direct-download-just-include-this-file-in-your-script)

[MyLogPHP.class.php](https://raw.githubusercontent.com/llagerlof/MyLogPHP/master/MyLogPHP.class.php) (1.2.19)
### Or you can use Composer

[](#or-you-can-use-composer)

Edit your project's \*\*composer.json\*\* and add the required package: \*\*"llagerlof/mylogphp": "dev-master"\*\* Eg:

```
{
    "name": "your/project",
    "require": {
        "llagerlof/mylogphp": "dev-master"
    }
}

```

How to read the generated log file
----------------------------------

[](#how-to-read-the-generated-log-file)

Any CSV reader can be used to open the generated logs, but If you need a recomendation, try the [CSVFileView](http://www.nirsoft.net/utils/csv_file_view.html) or [LogExpert](http://www.log-expert.de). Both can parse/show the CSV columns and watch realtime changes in log file (like tail on Linux). Features
--------

[](#features)

- One single file to rule them all!
- Super easy start.
- Two extra columns are automatically added in the CSV: the number of execution line and the path of host script where the log was called.
- Minimum PHP version: 5.3

Want more features? I am listening!
-----------------------------------

[](#want-more-features-i-am-listening)

Create an issue in

Quick start
-----------

[](#quick-start)

Include in your script the file "MyLogPHP.class.php" (not needed if you are using the composer version).

```
include('MyLogPHP.class.php');
```

Instantiate the object. Optionally you can pass the log file name and the separator as a parameter. Default log file name is "`_`MyLogPHP-1.2.log.csv" in current folder, and default separator is comma (,).

```
$log = new MyLogPHP\MyLogPHP('./log/debug.log.csv');
```

Make sure the directory where the log will be created is writable.

Call method "info", "warning", "error" or "debug" to write the messages. The first parameter is the message, the optional second parameter is a free tag at your choice to help you filter the log when opened by an spreadsheet software, like `OpenOffice Calc` or `Microsoft Excel`.

```
$log->info('This message will be logged in the file debug.log.csv','TIP');
```

That's it!

Examples
--------

[](#examples)

```
$log = new MyLogPHP\MyLogPHP();

$log->info('The program starts here.');

$log->warning('This problem can affect the program logic');

$log->warning('Use this software at your own risk!');

$log->info('Lawrence Lagerlof','AUTHOR');

$log->info('Asimov rulez','FACT');

$log->error('Everything crash and burn','IE');

$log->debug("select * from table",'DB');
```

Writing a variable content to file "\_OUT\_MyLogPHP.txt"

```
\MyLogPHP\MyLogPHP::out($data);

\MyLogPHP\MyLogPHP::out($data, array('LABEL' => 'variable $data');

\MyLogPHP\MyLogPHP::out($data, 'variable $data'); // same as above

\MyLogPHP\MyLogPHP::out($data, array('LABEL' => 'variable $data', 'WRITE_MODE' => MyLogPHP::OVERWRITE));

\MyLogPHP\MyLogPHP::out($data, array('LABEL' => 'variable $data', 'WRITE_MODE' => MyLogPHP::APPEND)); // WRITE_MODE can be OVERWRITE or APPEND (APPEND is default)

```

Changelog
---------

[](#changelog)

**1.2.19**

- Read the configuration file only once per instance.

**1.2.18**

- Namespace added.

**1.2.17**

- Fixed a debug\_backtrace problem when used in Laravel application.

**1.2.16**

- Put an optional config file (MyLogPHP.conf in the same directory of the class) with one line containing "enabled=false" to disable logging.

**1.2.15**

- Changed output format of out() method.

**1.2.14**

- Added method name to output of the out() method.

**1.2.13**

- Added the file and execution line info to output of the out() method.

**1.2.12**

- You can define a $\_SESSION variable to set where the file will be created by the out() method.

**1.2.11**

- out() method is now static.

**1.2.10**

- Can pass a string to act as LABEL to the second parameter of out() method.

**1.2.9**

- Removed supressed warnings from variable $headers and date() functions.

**1.2.8**

- Add more options and verbosity to out() method.

**1.2.7**

- New method out() allow append a variable value to the end of the file \_OUT\_MyLogPHP.txt

**1.2.6**

- Class updated for PHP 7 (thanks [@clintre](https://github.com/clintre)).

**1.2.5**

- Solved a bug that was preventing the replacement of consecutives spaces and tabs for one space.

**1.2.4**

- All consecutives spaces and tabs are removed from output.

**1.2.3**

- PHPDOC comment style applied to the class.
- An issue with the newer version of PHP and the date() function was solved.

**1.2.2**

- Line breaks of VALUE field are converted to spaces to prevent some CSV readers wrongly interpret line breaks as new CSV lines.
- The VALUE field now is trimmed before output.

**1.2.1**

- Disable a warning message if an internal variable is not set.

**1.2**

- Two columns added in CSV output: LINE and FILE.

**1.1**

- Added support to choose the field separator. Comma is still the default.

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity31

Early-stage or recently created project

 Bus Factor1

Top contributor holds 97.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/193798?v=4)[Lawrence](/maintainers/llagerlof)[@llagerlof](https://github.com/llagerlof)

---

Top Contributors

[![llagerlof](https://avatars.githubusercontent.com/u/193798?v=4)](https://github.com/llagerlof "llagerlof (35 commits)")[![clintre](https://avatars.githubusercontent.com/u/3766215?v=4)](https://github.com/clintre "clintre (1 commits)")

### Embed Badge

![Health badge](/badges/llagerlof-mylogphp/health.svg)

```
[![Health](https://phpackages.com/badges/llagerlof-mylogphp/health.svg)](https://phpackages.com/packages/llagerlof-mylogphp)
```

###  Alternatives

[psr/log

Common interface for logging libraries

10.4k1.2B11.5k](/packages/psr-log)[open-telemetry/api

API for OpenTelemetry PHP.

1941.5M276](/packages/open-telemetry-api)[open-telemetry/sdk

SDK for OpenTelemetry PHP.

2328.5M343](/packages/open-telemetry-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
