Documentation / @agentick/core / Logger
Variable: Logger
constLogger:object
Defined in: kernel/src/logger.ts:365
Logger singleton for Agentick applications.
Provides structured logging with automatic context injection from the current execution context (via AsyncLocalStorage).
Type Declaration
level
Get Signature
get level():
LogLevel
Get the current log level.
Returns
child()
child(
bindings):KernelLogger
Create a child logger with custom bindings.
Parameters
bindings
Record<string, unknown>
Key-value pairs to include in every log
Returns
Child logger with bindings
Example
const requestLog = Logger.child({ request_id: req.id });
requestLog.info('Handling request');configure()
configure(
config):void
Configure the global logger. Should be called once at application startup.
Parameters
config
Logger configuration
Returns
void
Example
Logger.configure({
level: process.env.LOG_LEVEL ?? 'info',
transport: {
targets: [
{ target: 'pino-pretty', options: { colorize: true } },
{ target: 'pino/file', options: { destination: './logs/app.log' } },
],
},
});create()
create(
config?):KernelLogger
Create a standalone logger instance with custom config. Does not affect the global logger.
Parameters
config?
LoggerConfig = {}
Logger configuration
Returns
New logger instance
Example
const auditLog = Logger.create({
level: 'info',
transport: { target: 'pino/file', options: { destination: './audit.log' } },
});for()
for(
nameOrComponent):KernelLogger
Create a child logger scoped to a component or name.
Parameters
nameOrComponent
Component name or object (uses constructor.name)
string | object
Returns
Child logger with component binding
Example
// With string name
const log = Logger.for('CalculatorTool');
// With object (uses class name)
class MyAgent {
private log = Logger.for(this);
}get()
get():
KernelLogger
Get the global logger instance. Context is automatically injected into every log.
Returns
KernelLogger instance
Example
const log = Logger.get();
log.info('Processing', { items: 5 });
// Output includes executionId, userId, trace_id, etc.isLevelEnabled()
isLevelEnabled(
level):boolean
Check if a level is enabled.
Parameters
level
Log level to check
Returns
boolean
true if the level is enabled
reset()
reset():
void
Reset the global logger (mainly for testing).
Returns
void
setLevel()
setLevel(
level):void
Set the log level at runtime.
Parameters
level
New log level
Returns
void
Example
// Configure at app startup
Logger.configure({ level: 'debug' });
// Get logger (context auto-injected)
const log = Logger.get();
log.info('Request received');
// Create child logger for a component
const componentLog = Logger.for('MyComponent');
componentLog.debug('Initializing');
// Or from an object (uses constructor name)
class MyTool {
private log = Logger.for(this);
}