Error encountered while configuring the log4js function in a NodeJs environment

Encountering an issue with my NodeJs application where I'm using log4js for logging. The error in the console window is related to a syntax problem while running in the express runtime platform.

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: Seeking insights on how to resolve this potential parsing error.

Thanks,

Answer №1

Experiencing issues on a Windows system? Occasionally, parsers can become disrupted by \r\n (carriage returns). Consider converting the lines to UNIX style (new line only) format.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

At first, struggling to dynamically adjust the height of a collection view based on JSON data in a Swift project

Within a tableview cell, I am utilizing a collection view. When I return homeData?.result?.category_json?.count ?? 0 to populate the collection view with JSON data, the height of the collection view does not adjust dynamically at first. However, when I scr ...

Access the contents of objects during the creation process

I am currently in the process of creating a large object that includes API path variables. The challenge I am facing is the need to frequently modify these API paths for application migration purposes. To address this, I had the idea of consolidating base ...

Using jQuery to pass dynamic values to a plugin function

I'm currently utilizing the JSONTable plugin and attempting to dynamically pass values to the 'head' and 'json' parameters by extracting them from an array object. For instance, I aim to load a new json file, convert it to a JavaSc ...

Utilizing Next.js and Express as middleware, I am looking to configure the routes 'localhost:3000/newpage' and 'localhost:3000/newpage/' to be treated as the same route. How can I achieve this synchronization between the

I recently started using express and next, and encountered an issue while trying to set 'localhost:3000/newpage' and 'localhost:3000/newpage/' as the same route. Whenever I add a '/' at the end, it triggers a 404 error. For d ...

The rounding of my image is uneven across all sides

I'm attempting to give my image rounded borders using border-radius, but I'm unsure if the overflow property is affecting the image. Image 1 shows my current image, while Image 2 depicts what I am trying to achieve. I am utilizing React, HTML, no ...

Flatbuffers does not exist in this context

Currently, I am working on a nodeJs application that involves the use of Google Flat Buffer. After installing flatc on my MacBook Pro, I compiled the schema below: namespace MyAlcoholist; table Drink { drink_type_name: string; drink_company_name: stri ...

Vue CLI Plugin Electron Builder displays a completely empty screen after compiling

After building my electron app using this specific plugin, I encountered a frustrating issue where the installed package would only display a blank, white screen. Despite setting up the window to open dev tools in the built version, inspecting the page rev ...

What could be the reason for node js version 8.xx being installed yet displaying version v6.3.1?

My CentOS 7 server is currently running Node.js version 6.3.1 To update to version 8.x of Node.js, I used the following commands: curl --silent --location https://rpm.nodesource.com/setup_8.x | sudo bash - and sudo yum -y install nodejs After executin ...

Encountering an error message saying "npm install leads to Cannot read property 'name' of undefined"

After running npm i, I encountered the following error message: npm i npm ERR! Cannot read property 'name' of undefined npm ERR! A complete log of this run can be found in: npm ERR! /Users/minta-dan/.npm/_logs/2021-02-01T12_07_22_367Z-debug. ...

Is it possible for the req.url path in expressjs to represent a different URL?

Recently, I discovered some suspicious requests being sent to my node-express server. In response, I created a middleware to record the request URLs. After logging these requests, I noticed that most of them started with '/', but there were also ...

Unable to access socket.io server beyond local network

Welcome everyone! Using this amazing tool, I successfully set up port forwarding for port 3000. Here is the link: I decided to forward this port because my chat application works perfectly fine on localhost. However, when I asked my friends to access my ...

Decoding Json Search Results from Google Shopping

After experimenting with various examples from different sources, including the web, for a couple of weeks, I've hit a roadblock. While I can successfully retrieve the desired search results from Google Shopping: { "items": [ { "product": { "title ...

Guide to Displaying HTTP POST Request Response on Pug Template

Whenever a user interacts with the form, I initiate an HTTP POST request to the database server. Subsequently, the database server sends a POST request back to the user's server. The issue I am facing is the inability to display this database result ...

Build in Docker unsuccessful | Error code 4294967295 received from running the command '/bin/sh -c node -v' on Windows platform

Here is a simple Dockerfile I am attempting to create on the Windows Docker platform: docker build . -t nishantt95/my-node-app FROM node:16.14.2 WORKDIR /app COPY package*.json ./ RUN npm i COPY . ./ EXPOSE 3000 CMD ["npm", "start"] ...

Guide to testing my-sql database routes in an express application

Trying to test my NodeJS REST API has been a challenge due to most of my routes involving calls to a MySQL database. I've considered mocking or stubbing the database using Sinon, but have not had much success. Making real database calls in tests is no ...

Using Node.js to execute JavaScript with imported modules via the command line

Having limited experience with running JavaScript from the command line, I am facing a situation where I need to utilize an NPM package for controlling a Panasonic AC unit, which includes a wrapper for their unofficial API. My objective is to create a sim ...

Encountered an issue while trying to establish a TLS connection when downloading vscode-server using VSCode remote container

When attempting to connect to a container from Mac OS X, I encountered the following messages. [0 ms] Start: Resolving remote [1 ms] Setting up container rails_web_1 [43 ms] Start: Check Docker is running [70 ms] Start: Inspecting container [123 ms] Star ...

Is there a way to restrict the amount of RAM Nextjs uses during development?

I am currently working on a project using Nexjs with @mui/material. There is an ongoing issue regarding memory usage in Nextjs, which can be found on this GitHub link. Whenever I run the development server for a period of time, my laptop's RAM gets ...

I need guidance on how to successfully upload an image to Firebase storage with the Firebase Admin SDK

While working with Next.js, I encountered an issue when trying to upload an image to Firebase storage. Despite my efforts, I encountered just one error along the way. Initialization of Firebase Admin SDK // firebase.js import * as admin from "firebas ...

A comprehensive guide on displaying an image with node.js and react.js

I need to showcase images on the frontend. The images are stored in a PostgreSQL database with a static path. I've been attempting to configure an Express server to serve these images, but so far, it's not functioning as intended. Here is the co ...