1.6 KiB
Set up logging
ZenStack uses the following levels to control server-side logging:
-
errorError level logging
-
warnWarning level logging
-
infoInfo level logging
-
verboseVerbose level logging
-
queryDetailed database query logging
By default, ZenStack prints error and warn level of logging with console.error and console.log, respectively. You can also control the logging behavior by providing a zenstack.config.json file at the root of your project.
You can turn log levels on and off in zenstack.config.json:
{
"log": ["verbose", "info"]
}
The settings shown above is an shorthand for:
{
"log": [
{
"level": "verbose",
"emit": "stdout"
},
{
"level": "info",
"emit": "stdout"
}
]
}
You can also configure ZenStack to emit log as event instead of dumping to stdout, like:
{
"log": [
{
"level": "info",
"emit": "event"
}
]
}
To consume the events:
import service from '@zenstackhq/runtime';
service.$on('info', (event) => {
console.log(event.timestamp, event.message);
});
You can also mix and match stdout output with event emitting, like:
{
"log": [
{
"level": "info",
"emit": "stdout"
},
{
"level": "info",
"emit": "event"
}
]
}
The settings in zenstack.config.json controls logging of both ZenStack and the underlying Prisma instance.