Comments (2)
To my knowledge, it's configurable in winston itself – there's a filter for what levels get sent to transports.
So, all these should work (considering you enable silly logs to be passed to transports):
{
error: 0,
warn: 1,
info: 2,
http: 3,
verbose: 4,
debug: 5,
silly: 6
}
from winston-loki.
Found the answer at https://github.com/winstonjs/winston#logging-levels
winston allows you to define a level property on each transport which specifies the maximum level of messages that a transport should log. For example, using the syslog levels you could log only error messages to the console and everything info and below to a file (which includes error messages):
const logger = winston.createLogger({
levels: winston.config.syslog.levels,
transports: [
new winston.transports.Console({ level: 'error' }),
new winston.transports.File({
filename: 'combined.log',
level: 'info'
})
]
});
You may also dynamically change the log level of a transport:
const transports = {
console: new winston.transports.Console({ level: 'warn' }),
file: new winston.transports.File({ filename: 'combined.log', level: 'error' })
};
const logger = winston.createLogger({
transports: [
transports.console,
transports.file
]
});
logger.info('Will not be logged in either transport!');
transports.console.level = 'info';
transports.file.level = 'info';
logger.info('Will be logged in both transports!');
from winston-loki.
Related Issues (20)
- Enable `replaceTimestamp` by default HOT 1
- Winston-loki not working with Grafana Cloud Loki HOT 3
- I cannot start project HOT 1
- use Symbol.for('level') when extracting label HOT 1
- useCustomFormat is broken
- Race condition in batching leading to lost logs HOT 1
- Feature Request: awaitable finishRequests method
- TypeError: winston_loki_1.default is not a constructor HOT 2
- Remote Loki HOT 1
- Possible to quit the batcher loop ASAP when closing? HOT 1
- [patch] A method to wait until all the logs are physically sent to winston HOT 3
- Docs: Add a section to explain how to make it work with nextjs and/or webpack HOT 5
- Snappy optionalDependency upgrade breaks build HOT 2
- CVE-2023-36665 protobufjs Dependency HOT 3
- Childlogger with additional labels
- NodeJS crash when batching is enabled
- Segmentation fault with swc & vitest in github action ubuntu-latest when using version 6.0.7
- Documentation improvement ideas
- logfmt syntax error with Grafana cloud
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from winston-loki.