3

I am new in node and I need to have a log file which stores error log details I need guidance to make log file generated using typescript (node)

3
  • 1
    nodejs.org/api/fs.html#fs_class_fs_writestream Commented Nov 28, 2017 at 13:12
  • You can also take look at Winston Commented Nov 28, 2017 at 13:14
  • dear @SelloMkantjwa would give me some link where I can refer to typescript version fo Winston because I google it but all are in js example Commented Nov 28, 2017 at 13:43

1 Answer 1

2

Hi use log4js module,

var log4js = require('log4js'); //include
var errorLog = {
  module: "module name",
  location: "location name",
  line: "72",
  message: err //error object
};
log4js.getLogger().error(errorLog); //writing log file

go through with the log4js documentation for more details about configuration

Sign up to request clarification or add additional context in comments.

2 Comments

log4js is also available for typescript? because my node is on typescript
you can use log4ts instead if you are fully using typescript.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.