NodeJS writes log file (Json)
I want to write logs to Json file
newEntry = "User: " + lastUsername + " Time: "+now+ " Door: "+IOSDoor;
lastUserOpenClose += newEntry;
jsonString = JSON.stringify(lastUserOpenClose);
fs.writeFile("lastUserOpenClose.json", lastUserOpenClose, function(err) {
if(err) {
console.log(err);
} else {
console.log("Server-Log: The file was saved!");
}
});
But I'm rewriting magazines. How can I write somthing to a json file and not overwrite old logs?
+3
source to share