app.Logger() provides access to a standard slog.Logger implementation that writes any logs into the database so that they can be later explored from the PocketBase Dashboard > Logs section.

All standard slog.Logger methods are available but below is a list with some of the most notable ones.

With(atrs...) creates a new local logger that will "inject" the specified attributes with each following log.

WithGroup(name) creates a new local logger that wraps all logs attributes under the specified group name.

The logs are usually meant to be filtered from the UI but if you want to programmatically retrieve and filter the stored logs you can make use of the app.LogQuery() query builder method. For example:

If you want to modify the log data before persisting in the database or to forward it to an external system, then you can listen for changes of the _logs table by attaching to the base model hooks. For example: