I’m a novice trying to make a server.log file in a node app built on Express (see code below). Unfortunately server.log won’t show up in the folder. Maybe the File System works different when used locally than on Glitch?
app.use((req, res, next) => {
var now = new Date().toString();
var log = ${now};
console.log(log);
fs.appendFile(“server.log”, log + “\n”, (err) => {
if (err) {
console.log(“Unable to append to server.log”);
}
});
next();
});
Oh wait, something similar just happened to me. When I tried to add a server.log, it didn’t show up and when I tried to add it as a new file, it said it was gitignored, although I didn’t have one. So here is how you fix it:
Create a .gitignore file if you don’t have one.
In the gitignore, type !server.log
Type refresh in the Glitch Console to restart the project.
Thanks guys! Now I can see my log file and I understand why it should not be in the git repo I will let it be excluded except for when I want to have a look in it.