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)
-
1nodejs.org/api/fs.html#fs_class_fs_writestreampawel– pawel2017-11-28 13:12:52 +00:00Commented Nov 28, 2017 at 13:12
-
You can also take look at WinstonSello Mkantjwa– Sello Mkantjwa2017-11-28 13:14:22 +00:00Commented 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 exampleAmit Singh Rawat– Amit Singh Rawat2017-11-28 13:43:59 +00:00Commented Nov 28, 2017 at 13:43
Add a comment
|
1 Answer
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
2 Comments
Amit Singh Rawat
log4js is also available for typescript? because my node is on typescript
Sultan Khan
you can use log4ts instead if you are fully using typescript.