slf4ts-winston
TypeScript icon, indicating that this package has built-in type declarations

1.3.0 • Public • Published

slf4ts-winston

Winston Logging-Binding for slf4ts

NPM Version License Dependencies Status

It's meant to be used with nodejs.

Currently not supported:

  • using custom log-levels

Example Usage

Example package.json:

{
    ...,
    "dependencies": {
        "slf4ts-winston": "latest"
    },
    ...
}

Example code:

import { LoggerFactory, LoggerConfiguration } from "slf4ts-api";
// register winston third-party-lib
import "winston-daily-rotate-file";
 
const ROOT_LOGGER = LoggerFactory.getLogger();
ROOT_LOGGER.setMetadata({ application: 'my-app' });
 
ROOT_LOGGER.info("Test Message", { version: '1.0.0' }, new Error());
 
// configuration for winston loggers
const config = {
    transports: [
        new (winston.transports.Console)(),
        new (winston.transports.File)({ filename: 'somefile.log' }),
        new (winston.transports.DailyRotateFile)({
            "filename": "logfilename-%DATE%.log",
            "datePattern": "YYYY-MM-DD",
            "logstash": true,
            "level": "debug"
        })
    ]
};
 
// configure the root logger ...
LoggerConfiguration.setConfig(config);
 
// configure a certain logger
LoggerConfiguration.setConfig(config, "my-lib", "X");

License

MIT

Package Sidebar

Install

npm i slf4ts-winston

Weekly Downloads

28

Version

1.3.0

License

MIT

Unpacked Size

29 kB

Total Files

19

Last publish

Collaborators

  • rstiller