> For the complete documentation index, see [llms.txt](https://cherrycake.tin.cat/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cherrycake.tin.cat/version-0.x/guide/log-guide/loading-systemlog-events-from-the-database.md).

# Loading Log events from the database

Since the [LogEvent](/version-0.x/reference/core-classes/logevent.md) class extends the [Item](/version-0.x/reference/core-classes/item.md) class, and the [LogEvents](/version-0.x/reference/core-classes/logevents.md) class extends the [Items](/version-0.x/reference/core-classes/items.md) class, you can use them to load lists of [LogEvent](/version-0.x/reference/core-classes/logevent.md) objects from the database to work with.

For example, let's load the last fifty [LogEvent](/version-0.x/reference/core-classes/logevent.md) objects from the [Log](/version-0.x/reference/core-modules/log.md) database, using what we learned in the [Item lists](/version-0.x/guide/items-guide/item-lists.md) section of the [Items guide](/version-0.x/guide/items-guide.md):

```php
$logEvents = new \Cherrycake\Log\LogEvents([
	"p" => [
		"limit" => 50
	]
]);

foreach ($logEvents as $logEvent) {
	echo
		"[".$e->Locale->formatTimestamp($logEvent->dateAdded, ["isHours" => true, "isSeconds" => true])."] ".
		$logEvent->type.
		"\n";
}
```

The [LogEvents](/version-0.x/reference/core-classes/logevents.md) class accepts some additional keys on top of the usual [Items::fillFromParameters](/version-0.x/reference/core-classes/items/items-methods.md#fillfromparameters) keys:

* **`type`** Retrieves only [LogEvent](/version-0.x/reference/core-classes/logevent.md) objects of this class name. Must include the full namespace route to the class.
* **`fromTimestamp`** Retrieves [LogEvent](/version-0.x/reference/core-classes/logevent.md) objects triggered after this timestamp.
* **`toTimestamp`** Retrieves [LogEvent](/version-0.x/reference/core-classes/logevent.md) objects triggered up to this timestamp.

```
[5/26/20 11:22.24] CherrycakeApp\LogEventMovieSearch
[5/26/20 10:55.28] CherrycakeApp\LogEventMovieSearch
[5/26/20 10:55.25] CherrycakeApp\LogEventMovieSearch
```

{% hint style="success" %}
See this example working in the [Cherrycake documentation examples](https://documentation-examples.cherrycake.io/example/movieSearchLog) site.
{% endhint %}
