20
rated 0 times
[
22]
[
2]
/ answers: 1 / hits: 38087
/ 9 Years ago, sat, january 9, 2016, 12:00:00
In my node.js project I use log4js and I want my logs to have name of the file where log record was added. So I use __filename but it gives me absolute path
var logger = log4js.getLogger(__filename)
So it gives me logs like this:
[1999-01-01 00:00:00] [DEBUG] /Users/whatever/myproject/src/services/users something happened
But I want the path to be relative to my project/src folder. Like this:
[1999-01-01 00:00:00] [DEBUG] services/users something happened
What is the best way to achieve this?
More From » node.js