Skip to content

How to write logs in a file? #556

@saeta-eth

Description

@saeta-eth

Hi all.

I want to do something like it: https://stackoverflow.com/a/26731285/1741027
But I dont know why it return log4js.loadAppender is not a function

I added in each js file this code:
const path = require('path')
const log4js = require('log4js')
const fileName = path.basename(__filename, path.extname(__filename))

log4js.loadAppender('file')
log4js.addAppender(log4js.appenders.file('logs/'+ fileName +'.log'), fileName)

const logger = log4js.getLogger(fileName)

Is there a way to get the same behavior?
Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions