# Logging

{% hint style="warning" %}
**This is the manual for older MicroStream versions (Version < 5.0).**

**The new documentation (Version >= 5.0) is located at:**

[https://docs.microstream.one/](https://docs.microstream.one/manual)
{% endhint %}

Another predefined logic layer is for logging purposes. Since there is a myriad of loggers out there, MicroStream doesn't provide any special adapter, but a generic type which can be used to adapt to the logging framework of your choice.

Just create a class and implement `EntityLogger`, and you are good to go.

```java
public class JulLogger implements EntityLogger
{
	@Override
	public void afterUpdate(
		final Entity identity, 
		final Entity data, 
		final boolean successful)
	{
		Logger.getLogger(identity.getClass().getName())
			.info("Entity updated");
	}
}
```

Additional to `afterUpdate` there are further hooks:

* `entityCreated`
* `afterRead`
* `beforeUpdate`

Now just add the logger when creating entities:

```java
JulLogger logger = new JulLogger();

Person john = PersonCreator.New()
	.addLayer(logger)
	.firstName("John")
	.lastName("Doe")
	.create();
```

When you call

```java
PersonUpdater.setLastName(john, "Smith");
```

the logger's output is

```
Oct 15, 2019 11:17:53 AM JulLogger afterUpdate
INFO: Entity updated
```


---

# 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://manual.docs.microstream.one/3.0/basic-concepts/layered-entities/logging.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.
