log4js configure function error [NodeJs]

1.5k Views Asked by At

I am getting the following error in console window when running my NodeJs application. I am using log4js for logging. Runtime platform is express.

Error:

undefined:1
?{
^
SyntaxError: Unexpected token ? in JSON at position 0

Code:

var log4js = require('log4js');
var mylog = log4js.configure('log4jsConfig.json');
logger = log4js.getLogger("absolute-logger");

Config json:

{
    "appenders": [
              {
            "type": "file",
            "absolute": true,
            "filename": "c:/temp/log_file.log",
            "maxLogSize": 20480,
            "backups": 10,
            "category": "absolute-logger"
        }
    ]
}

Question: Any thoughts. I am thinking this is parsing error, but not sure how to resolve it.

Thanks,

1

There are 1 best solutions below

0
On

Are you on a windows system? Sometimes, parsers get upset with \r\n (carriage returns). Try converting it UNIX (new line only) style lines.