Questions tagged [log4js-node]

log4js-node is a logging framework for Node.js. (Not to be confused with log4js, since log4js-node is a different software.)

log4js-node is a conversion of the log4js framework to work with node.

121 questions
21
votes
1 answer

log4js-node-DEP0004 - Deprecation warning in Angular 12 karma unit tests

I'm getting the following deprecation warning when running unit tests in a brand new Angular 12 application: (node:14940) [log4js-node-DEP0004] DeprecationWarning: Pattern %d{DATE} is deprecated due to the confusion it causes when used. Please use…
tao
  • 82,996
  • 16
  • 114
  • 150
16
votes
4 answers

write logs in file using log4js in node js

my code is: log4js.loadAppender('file'); log4js.addAppender(log4js.appenders.file('logs/cheese.log'), 'cheese'); logger.setLevel('DEBUG'); logger.trace('Entering cheese testing'); logger.debug('Got cheese.'); logger.info('Cheese is…
Mahendra
  • 301
  • 2
  • 3
  • 10
13
votes
1 answer

Is Log4JS npm package vulnerable to CVE-2021-44228 Log4J vulnerability

As the title says. Looked online for a clear answer but can't find an answer anywhere as most of them just link to Log4J.
Andrew
  • 186
  • 1
  • 10
9
votes
5 answers

Disable console printing in Log4js

I just enabled logging using Log4js in my Node.js application. I have used the config option from https://github.com/nomiddlename/log4js-node and it's working fine. It writes the logs in the log file, as well as in the console. I do not want this to…
user644745
  • 5,673
  • 9
  • 54
  • 80
5
votes
2 answers

log4js appenders with different levels of logging levels

I'm trying to create a logger configuration which logs only "ERROR" level information to console and "DEBUG" level information to file appenders. Can anyone help on how to create a logger with above config? Thanks in advance. Help is very much…
balakrishna
  • 279
  • 2
  • 6
  • 12
5
votes
3 answers

Log4js javascript create daily log file

I have a project nodejs and use log4js to write log. I want create new file log when start new date. Example: daily.2017_07_31.log daily.2017_08_01.log daily.2017_08_02.log daily.2017_08_03.log In java, I know config log4j but in nodejs…
phuchoangmai
  • 305
  • 1
  • 5
  • 15
5
votes
2 answers

Is there any way in nodejs to print log4js output in JSON format?

I am trying to get output of log4js in JSON format so I can easily trace it. Is there any way that we have to set in configuration.json so output produced by log4js will be in JSON format? Currently I am using following config. { "appenders": [ { …
Pravin Bhapkar
  • 463
  • 1
  • 5
  • 15
5
votes
0 answers

how to use log4js in test case with karma?

currently I need to add log4js support in my test case, like below: it(' QuestionController saveQuestion method Testing ', inject(function(localStorageService) { ***var log4js = require('log4js'); var logger = log4js.getLogger(); …
jason.zhan
  • 51
  • 2
4
votes
2 answers

write logs with log4js in new diffrent files?

I want to write the logs into different files. const log4js = require('log4js'); log4js.configure({ appenders: { integra: { type: 'file', filename: './logs/doc.log' } }, categories: { default: { appenders: ['doc'], level: 'error' }…
TechChain
  • 8,404
  • 29
  • 103
  • 228
4
votes
3 answers

How to exclude a log4js category from being logged to the default appenders

I'm using node-log4js. (it's log4JS, not log4J!) I thought of the loggers 'categories' to be just like the Strings you put in Log4J into the constructor of a logger (normally you put your fqn class name there), so that log4j can put logged things to…
Mitja
  • 1,969
  • 30
  • 35
3
votes
2 answers

How to mock a call to logger.warn?

I'm practicing test-first development and I want to ensure that method in a class always calls my logger at the warn level with a message. My class is defined like so: import { log4js } from '../config/log4js-config' export const logger =…
tenfishsticks
  • 452
  • 5
  • 13
3
votes
2 answers

log4js for Node doesn't output to file, only to console

I need a basic logging system for a NodeJS application, so I'm doing some tests with log4js, which seems to be the standard for these cases. I need to print the messages both to the console and a file, so I wrote this code: // Logger var log4js =…
Fel
  • 4,428
  • 9
  • 43
  • 94
3
votes
0 answers

log4js fs dependency error

I am trying to integrate the latest version of log4js (techically log4js-node but it seems log4js is now used for the latter) into a React Native project. I installed the package using Yarn 1.0.2 and wrote a few lines of code just to test the…
user1849060
  • 621
  • 3
  • 10
  • 20
3
votes
1 answer

Connect multiple log4js appender with express in node

I want to log all activities on my express server on console as well as in log file. var log = log4js.getLogger(); log.info(), log.error()....etc works fine Also if I connect it with express like app.use(log4js.connectLogger(log, { level: 'auto'…
Rahul Bhooteshwar
  • 1,675
  • 17
  • 31
3
votes
3 answers

Log4js: logs depend on NODE_ENV

How can I make logs (INFO, ERROR) dependent on set NODE_ENV? I mean, for example, if NODE_ENV=development, I write only ERROR logs. With NODE_ENV=production, there has to be only INFO. How should I modify appenders to perform this? Thanks for your…
a-a
  • 472
  • 2
  • 6
  • 20
1
2 3
8 9