# Loading Log events from the database

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

For example, let's load the last fifty [LogEvent](/reference/core-classes/logevent.md) objects from the [Log](/reference/core-modules/log.md) database, using what we learned in the [Item lists](/guide/items-guide/item-lists.md) section of the [Items guide](/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](/reference/core-classes/logevents.md) class accepts some additional keys on top of the usual [Items::fillFromParameters](/reference/core-classes/items/items-methods.md#fillfromparameters) keys:

* **`type`** Retrieves only [LogEvent](/reference/core-classes/logevent.md) objects of this class name. Must include the full namespace route to the class.
* **`fromTimestamp`** Retrieves [LogEvent](/reference/core-classes/logevent.md) objects triggered after this timestamp.
* **`toTimestamp`** Retrieves [LogEvent](/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 %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cherrycake.tin.cat/guide/log-guide/loading-systemlog-events-from-the-database.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
