How to set the default logger in TypeScript
Set the DefaultLogger
to one of the following log levels: 'TRACE'
| 'DEBUG'
| 'INFO'
| 'WARN'
| 'ERROR'
.
The following is an example of setting the DefaultLogger
to 'Debug'
.
Runtime.install({
logger: new DefaultLogger('DEBUG'),
telemetryOptions: {
tracingFilter: 'temporal_sdk_core=DEBUG',
logging: { forward: { level: 'DEBUG' } },
},
});
The following code sets the DefaultLogger
to 'Debug'
and creates a Worker that can execute Activities or Workflows.
import { Worker, Runtime, DefaultLogger } from '@temporalio/worker';
import * as activities from './activities';
async function main() {
const argv = arg({
'--debug': Boolean,
});
/* Setting the log level to DEBUG. */
if (argv['--debug']) {
Runtime.install({
logger: new DefaultLogger('DEBUG'),
telemetryOptions: {
tracingFilter: 'temporal_sdk_core=DEBUG',
logging: { forward: { level: 'DEBUG' } },
},
});
}
const worker = await Worker.create({
activities,
workflowsPath: require.resolve('./workflows'),
taskQueue: 'test',
});
await worker.run();
console.log('Worker gracefully shutdown');
}