# Logging

{% hint style="danger" %}
**Please note:** This page is under construction and has not been finished yet.
{% endhint %}

## **Introduction**

You can log events to the admin [System Logs](https://userguide.e107.org/administration/tools/system-logs) by using the built in log class.\
\
Use the following to retrieve the alerts class object.&#x20;

```php
$log = e107::getLog();
```

## Logging methods

### add()

| Parameter | Description                                                                                            |
| --------- | ------------------------------------------------------------------------------------------------------ |
| name      | Title or name for the log event.                                                                       |
| details   | Details for the log event - can be either a string of text or an array.                                |
| type      | The type of event. ([see table below](#logging-types))                                                 |
| code      | Custom reference code for your type of event. It should be short, ALL CAPITALS and not contain spaces. |

```php
$log = e107::getLog();
$log->add(name, details, type, code);

//Example: 
$log->add('My Event Name', $myDetailedData, E_LOG_INFORMATIVE, 'MYCODE');
```

## Logging types

| Type                | Description         |
| ------------------- | ------------------- |
| E\_LOG\_INFORMATIVE | Informational event |
| E\_LOG\_NOTICE      | Notice event        |
| E\_LOG\_WARNING     | Warning event       |
| E\_LOG\_FATAL       | Fatal event         |
