PHPackages                             joomla/log - 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. [Framework](/categories/framework)
4. /
5. joomla/log

AbandonedArchivedJoomla-package[Framework](/categories/framework)

joomla/log
==========

Joomla Log Package

1.3.0(9y ago)45.0k4GPL-2.0+PHPPHP &gt;=5.3.10|&gt;=7.0CI failing

Since Jun 4Pushed 8mo ago13 watchersCompare

[ Source](https://github.com/joomla-framework/log)[ Packagist](https://packagist.org/packages/joomla/log)[ Docs](https://github.com/joomla-framework/log)[ RSS](/packages/joomla-log/feed)WikiDiscussions 1.x-dev Synced 1mo ago

READMEChangelogDependencies (8)Versions (10)Used By (0)

EOL
===

[](#eol)

This packages is no longer maintained and archived. No replacement by the Joomla Project is planned. Alternatives can be found at the [psr log package](https://packagist.org/packages/psr/log).

The Log Package [![Build Status](https://camo.githubusercontent.com/3e043021388968e34a15c8096b5ad1e68dc090bd6cabf3a6132144bac9210b7e/68747470733a2f2f63692e6a6f6f6d6c612e6f72672f6170692f6261646765732f6a6f6f6d6c612d6672616d65776f726b2f6c6f672f7374617475732e737667)](https://ci.joomla.org/joomla-framework/log)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

[](#the-log-package-)

[![Latest Stable Version](https://camo.githubusercontent.com/b639d63351c6f22f83862f6cf9990e21090c9d1a92865c64e7c9964f4bcf1a06/68747470733a2f2f706f7365722e707567782e6f72672f6a6f6f6d6c612f6c6f672f762f737461626c65)](https://packagist.org/packages/joomla/log) [![Total Downloads](https://camo.githubusercontent.com/4ab22e2662e3b01110c9db89e790d9f48d99d3b6f7058cebb5823388681b0281/68747470733a2f2f706f7365722e707567782e6f72672f6a6f6f6d6c612f6c6f672f646f776e6c6f616473)](https://packagist.org/packages/joomla/log) [![Latest Unstable Version](https://camo.githubusercontent.com/7d9212d45ee32494445a1fe16797bff4b355bf5f0b64f96215a19f973ed0ec1e/68747470733a2f2f706f7365722e707567782e6f72672f6a6f6f6d6c612f6c6f672f762f756e737461626c65)](https://packagist.org/packages/joomla/log) [![License](https://camo.githubusercontent.com/771a64ea11968790afe2c85622b333e0b35fe7663327d5c724a3fe0829d56427/68747470733a2f2f706f7365722e707567782e6f72672f6a6f6f6d6c612f6c6f672f6c6963656e7365)](https://packagist.org/packages/joomla/log)

### Deprecated

[](#deprecated)

The `joomla/log` package has been deprecated. No further updates are planned.

### Introduction

[](#introduction)

The Joomla Framework includes a Log package that allows for configurable, hook-driven logging to a variety of formats.

The classes included in the Log package are `Joomla\Log\Log`, `Joomla\Log\LogEntry`, `Joomla\Log\AbstractLogger` as well as the classes `Joomla\Log\Logger\Callback`, `Joomla\Log\Logger\Database`, `Joomla\Log\Logger\Echoo`, `Joomla\Log\Logger\FormattedText`, `Joomla\Log\Logger\Syslog` and `Joomla\Log\Logger\W3c` which support formatting and storage. Of all these classes, you will generally only use `Joomla\Log\Log` in your projects.

Logging is a two-step process.

First you must add the add loggers to listen for log messages. Any number of loggers can be configured to listen for log messages based on a priority and a category. For example, you can configure all log messages to be logged to the database, but also set just errors to be logged to a file. To do this, you use the `Joomla\Log\Log::addLogger` method.

After at least one logger is configured, you can then add messages using the `Joomla\Log\Log::addLogEntry` method where you can specify a message, and optionally a priority (integer), category (string) and date.

### Logging priority

[](#logging-priority)

Before we look at any logging examples, we need to understand what the priority is. The priority is an integer mask and is set using one or more predefined constants in the `Joomla\Log\Log` class. These are:

- Joomla\\Log\\Log::EMERGENCY
- Joomla\\Log\\Log::ALERT
- Joomla\\Log\\Log::CRITICAL
- Joomla\\Log\\Log::ERROR
- Joomla\\Log\\Log::WARNING
- Joomla\\Log\\Log::NOTICE
- Joomla\\Log\\Log::INFO
- Joomla\\Log\\Log::DEBUG

For information on what situation to use each constant in see the PSR-3 (Section 3) details here -  where a detailed explanation can be found.

A final constant, `Joomla\Log\Log::ALL` is also available which corresponds to hex FFFF (16 bits). The other constants reserve the first eight bits for system use. This allows the developer the last eight bits, hex 100 to 8000, for custom use if desired. As the values are for masking, they can be mixed using any of the bitwise operators for *and*, *or*, *not* and *xor*.

By default, loggers are added to listen for `Joomla\Log\Log::ALL` priorities and log entries are added using the `Joomla\Log\Log::INFO` mask.

### Logging to files *(formattedtext)*

[](#logging-to-files-formattedtext)

A very typical example of logging is the ability to log to a file, and this is the default handler for logging. To do this add the logger and then you can add log messages.

```
// Initialise a basic logger with no options (once only).
Joomla\Log\Log::addLogger(array());

// Add a message.
Joomla\Log\Log::add('Logged');
```

As no logger has been specified in the `Joomla\Log\Log::addLogger` call, the "formattedtext" logger will be used. This will log the message to a file called "error.php" in the log folder specified by the "log\_path" configuration variable (in the Joomla CMS, the default is `/logs/`). It will look something like this:

```
#
#Date: 2011-06-17 02:56:21 UTC
#Software: Joomla Framework 01-Jun-2011 06:00 GMT

#Fields: datetime   priority    category    message
2011-06-17T03:06:44+00:00   INFO    -   Logged

```

The file is tab-delimited and the default columns are the timestamp, the text representation of the priority, the category and finally the message. The category is empty (a dash) because we didn't supply it.

To log a different priority, you can use code like:

```
Joomla\Log\Log::add('Logged 3', Joomla\Log\Log::WARNING, 'Test');
```

The log file will now look similar to the following:

```
2011-06-17T03:06:44+00:00 INFO - Logged
2011-06-17T03:52:08+00:00 WARNING - Logged 2
2011-06-17T03:57:03+00:00 WARNING test Logged 3

```

#### Additional options with formattedtext

[](#additional-options-with-formattedtext)

When adding the "formattedtext" logger, the following options are available to supply in the array you pass to `Joomla\Log\Log::addLogger`.

OptionDescriptiontext\_fileAllows you to specify the name of the file to which messages are logged.text\_file\_pathAllows you to specify the folder path to the file to which messages are logged.text\_file\_no\_phpIf set, the PHP die statement will not be added to the file line of the file.text\_entry\_formatAllows you to change the format of the entire line of the log message in the file.### Changing the name of the log file

[](#changing-the-name-of-the-log-file)

Given the options outlined in the previous section, you can change the name of the file to which you are logging when you add the logger, like this:

```
// Log to a specific text file.
Joomla\Log\Log::addLogger(
	array(
		'text_file' => 'mylogs.php'
	)
);
```

#### Logging different priorities to different files

[](#logging-different-priorities-to-different-files)

You can log different types of messages to different files by adding multiple loggers that bind different log priorities to different files. For example, the following code will log all messages except errors to one file, and error messages to a separate file.

```
// Log all message except errors to mylogs.php.
Joomla\Log\Log::addLogger(
	array(
		'text_file' => 'mylogs.php'
	),
	Joomla\Log\Log::ALL ^ Joomla\Log\Log::ERROR
);

// Log errors to myerrors.php.
Joomla\Log\Log::addLogger(
	array(
		'text_file' => 'myerrors.php'
	),
	Joomla\Log\Log::ERROR
);
```

#### Logging specific categories to a file

[](#logging-specific-categories-to-a-file)

If you are wanting to collect errors for your specific project, class or extension, you can also bind logging to different categories. For example, the following code could be used in a Joomla extension to just collect errors relating to it.

```
// Log my extension errors only.
Joomla\Log\Log::addLogger(
	array(
		'text_file' => 'com_hello.errors.php'
	),
	Joomla\Log\Log::ERROR,
	'com_hello'
);
```

To log messages to that logger, you would use something similar to the following code:

```
Joomla\Log\Log::add('Forgot to say goodbye', Joomla\Log\Log::ERROR, 'com_hello');
```

It is important to note that other loggers, added beyond your control, may also pick up this message.

#### Splitting up logs by date

[](#splitting-up-logs-by-date)

Log files can, potentially, get very long over time. A convenient solution to this is to roll logs into different files based on a period of time - an hour, a day, a month or even a year. To do this, you just need to add the date to the file name of the log file. The following example shows you how to do this on a daily basis.

```
// Get the date.
$date = date('Y-m-d');

// Add the logger.
Joomla\Log\Log::addLogger(
	array(
		'text_file' => 'com_hello.'.$date.'.php'
	)
);
```

#### Changing the format of the log message

[](#changing-the-format-of-the-log-message)

When you adding a log message, it is written to the file in a default format in the form:

```
{DATETIME} {PRIORITY} {CATEGORY} {MESSAGE}

```

Each field is written in upper case, wrapped in curly braces and separated by tabs. There are a number of other fields that are automatically defined in the "formattedtext" logger that you can take advantage of automatically. These are:

FieldDescription{CLIENTIP}The IP address of the user.{DATE}The "Y-m-d" date component of the message datestamp.{TIME}The "H:i:s" time component of the message datestamp.To modify for the log format to add any or all of these fields, you can add the logger as shown in the following code.

```
// Add the logger.
Joomla\Log\Log::addLogger(
	array(
		'text_file' => 'com_hello.php',
		'text_entry_format' => '{DATE} {TIME} {CLIENTIP} {CATEGORY} {MESSAGE}'
	)
);
```

As you can see, you can include or leave out any fields as you require to suit the needs of your project.

You can also add more fields but to do this you need to create and add a `Joomla\Log\LogEntry` object directly. The following example shows you how to do this.

```
// Add the logger.
Joomla\Log\Log::addLogger(
	array(
		'text_file' => 'com_shop.sales.php',
		'text_entry_format' => '{DATETIME} {PRICE} {QUANTITY} {MESSAGE}'
	),
	Joomla\Log\Log::INFO,
	'Shop'
);

$logEntry = new Joomla\Log\LogEntry('T- Shirt', Joomla\Log\Log::INFO, 'Shop');
$logEntry->price = '7.99';
$logEntry->quantity = 10;

Joomla\Log\Log::add($logEntry);
```

It is strongly recommended that, when using a custom format, you bind the log entries to a specific and unique category, otherwise log files with different format *(fields)* could become mixed.

### Logging to the database

[](#logging-to-the-database)

The "database" logger allows you to log message to a database table. The create syntax for the default table is as follows:

```
CREATE TABLE `jos_log_entries` (
	`priority` int(11) DEFAULT NULL,
	`message` varchar(512) DEFAULT NULL,
	`date` datetime DEFAULT NULL,
	`category` varchar(255) DEFAULT NULL,
	KEY `idx_category_date_priority` (`category`,`date`,`priority`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
```

To log messages using the "database" logger, you the following code as a guide.

```
// Add the logger.
Joomla\Log\Log::addLogger(
	array(
		'logger' => 'database'
	),
	Joomla\Log\Log::ALL,
	'dblog'
);

// Add the message.
Joomla\Log\Log::add('Database log', Joomla\Log\Log::INFO, 'dblog');
```

Notice that the example binds the logger to all message priorities, but only those with a category of "dblog".

If you are wanting to store additional information in the message, you can do so using a JSON encoded string. For example:

```
// Assemble the log message. Assume a $user object.
$log = array(
	'userId' => $user->get('id'),
	'userName' => $user->get('name'),
	'stockId' => 'SKU123',
	'price' => '7.49',
	'quantity' => 10
);

// Add the message.
Joomla\Log\Log::add(json_encode($log), Joomla\Log\Log::INFO, 'dblog');
```

This makes it possible to retrieve detailed information for display.

Installation via Composer
-------------------------

[](#installation-via-composer)

Add `"joomla/log": "~1.0"` to the require block in your composer.json and then run `composer install`.

```
{
	"require": {
		"joomla/log": "~1.0"
	}
}
```

Alternatively, you can simply run the following from the command line:

```
composer require joomla/log "~1.0"
```

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance42

Moderate activity, may be stable

Popularity24

Limited adoption so far

Community22

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 51.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.

###  Release Activity

Cadence

Every ~140 days

Recently: every ~246 days

Total

9

Last Release

3606d ago

PHP version history (2 changes)1.0-alphaPHP &gt;=5.3.10

1.3.0PHP &gt;=5.3.10|&gt;=7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/305a2164440014dcef9ac681c139fe5e8a1ce1d7a8c3b3cfb828497729a4c70e?d=identicon)[wilsonge](/maintainers/wilsonge)

---

Top Contributors

[![mbabker](https://avatars.githubusercontent.com/u/368545?v=4)](https://github.com/mbabker "mbabker (42 commits)")[![photodude](https://avatars.githubusercontent.com/u/10253980?v=4)](https://github.com/photodude "photodude (10 commits)")[![dongilbert](https://avatars.githubusercontent.com/u/718028?v=4)](https://github.com/dongilbert "dongilbert (9 commits)")[![ianmacl](https://avatars.githubusercontent.com/u/176534?v=4)](https://github.com/ianmacl "ianmacl (8 commits)")[![realityking](https://avatars.githubusercontent.com/u/628508?v=4)](https://github.com/realityking "realityking (3 commits)")[![wilsonge](https://avatars.githubusercontent.com/u/1986000?v=4)](https://github.com/wilsonge "wilsonge (2 commits)")[![eddieajau](https://avatars.githubusercontent.com/u/700871?v=4)](https://github.com/eddieajau "eddieajau (2 commits)")[![HLeithner](https://avatars.githubusercontent.com/u/1497730?v=4)](https://github.com/HLeithner "HLeithner (2 commits)")[![PhilETaylor](https://avatars.githubusercontent.com/u/400092?v=4)](https://github.com/PhilETaylor "PhilETaylor (1 commits)")[![pborreli](https://avatars.githubusercontent.com/u/77759?v=4)](https://github.com/pborreli "pborreli (1 commits)")[![nibra](https://avatars.githubusercontent.com/u/827605?v=4)](https://github.com/nibra "nibra (1 commits)")[![Hackwar](https://avatars.githubusercontent.com/u/313866?v=4)](https://github.com/Hackwar "Hackwar (1 commits)")

---

Tags

joomlajoomla-frameworkloggingphppsr-3logframeworkjoomla

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/joomla-log/health.svg)

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

###  Alternatives

[cakephp/cakephp

The CakePHP framework

8.8k18.5M1.6k](/packages/cakephp-cakephp)[lanin/laravel-api-debugger

Easily debug your JSON API.

2311.8M](/packages/lanin-laravel-api-debugger)[yiisoft/log

Yii Logging Library

42917.2k26](/packages/yiisoft-log)[joomla/application

Joomla Application Package

23404.8k11](/packages/joomla-application)[joomla/registry

Joomla Registry Package

16468.6k20](/packages/joomla-registry)

PHPackages © 2026

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