slf4ts-winston

Winston logging-binding for slf4ts-api

Usage no npm install needed!

<script type="module">
  import slf4tsWinston from 'https://cdn.skypack.dev/slf4ts-winston';
</script>

README

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