Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

create log file using typescript in node application

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)

like image 975
Amit Singh Rawat Avatar asked Nov 25 '25 17:11

Amit Singh Rawat


1 Answers

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

like image 170
Sultan Khan Avatar answered Nov 28 '25 15:11

Sultan Khan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!