Core Development Concepts > Basics
Logger
Learn about Logger which we internally use
- what is the Logger
- how to use the Logger
Overview
Webiny logger is internal feature which we use to log errors and other information into a DynamoDB Log table.
For Logger to work, we deploy a new DynamoDB table called webiny-logs
.
How to Use Logger
To use the Logger in your project, you can access it from the Webiny context.
There are multiple levels of logging available:
debug
notice
info
warn
error
When you want to log something, you can use the following code:
Note that the where-did-the-log-come-from
is your custom string, which identifies where the log was created.
This is something you can use to filter logs later.
How to Access Logger Logs?
There are two ways to access the logs:
- directly from the DynamoDB table
webiny-logs
- using the GraphQL API
DynamoDB Table
You can access the logs directly from the DynamoDB table webiny-logs
. The table has the following structure:
The data is always compressed using GZIP, so you must decompress it before you can read it.
GraphQL API
You can also access the logs using the GraphQL API on /graphql
endpoint. There are multiple queries and mutations available:
listLogs
- to list all logsgetLog
- to get a single logdeleteLog
- to delete a singledeleteLogs
- to delete multiple logspruneLogs
- to delete all logs older than 60 seconds
List Logs
To list all logs, you can use the listLogs
query. Here is an example of the query:
All arguments in listTags
query are optional.
You can filter the logs by tenant
, source
and type
. Or you can just list all logs, without any filtering applied.
Prune Logs
To delete all logs older than 60 seconds, you can use the pruneLogs
mutation. Here is an example of the mutation:
The pruneLogs
mutation will actually start a background task that will delete the logs. The task ID will be returned in the response, so you can track its progress.
If you try to prune logs while another prune task is running, you will get an error.