Custom logging module that wraps winston 3.x
npm install --save newsource-winston-splunk-logger
import createLogger from "newsource-winston-splunk-logger";
// Minimum required configuration
const config = {
"appName": string
}
const loggerInstance = createLogger(config);
The LoggerConfig and other main types are located in one of:
dist/cjs/types/types.d.ts
dist/esm/types/types.d.ts
const config = {
appName: 'winston-splunk-logger-application',
splunk: {
index: 'winston-index',
level: 'silly', //optional
source: 'winston-environment',
sourcetype: 'winston-splunk-logger',
token: '123456789',
url: 'https://splunk.local:8088',
}
}
const config = {
appName: 'winston-splunk-logger-application',
email: {
host: 'smtp.local.com',
port: 2000,
from: 'test@local.com',
to: 'test@local.com',
}
}
const config = {
appName: 'winston-splunk-logger-application',
file: {
dirname: 'logs',
filename: 'application',
maxFiles: 10,
maxSize: 1000000
},
}
const config = {
appName: 'winston-splunk-logger-application',
formatForForwarding: true
}
This is for overriding or adding custom log levels.
const config = {
appName: 'winston-splunk-logger-application',
levels:{
mycustomlevel1: -1,
mycustomlevel2: -2,
mycustomlevel3: -3
}
}
const config = {
appName: 'newsource-winston-splunk-logger',
env: 'dev', // Used in subject like of Email logger
formatForForwarding: false,
level: 'silly', // Log level, defaults to silly
levels:{ // Custom levels (optional)
mycustomlevel1: -1,
mycustomlevel2: -2,
mycustomlevel3: -3
},
email: {
host: 'smtp.local.com',
port: 2000,
from: 'test@local.com',
to: 'test@local.com',
},
file: {
dirname: 'logs', // Directory for log files
filename: 'application', // Name prefix of log files
maxFiles: 10, // Max number of files
maxSize: 1000000 // In bytes
},
splunk: {
index: 'splunk-group',
source: 'splunk-environment',
sourcetype: 'application-name',
token: '123456789-123-123456',
url: 'https://splunk.example.com:2000',
}
}