0

I am trying to create a logfile where I want to write everything info/error/warn etc.

Below is my code where I can see the logs on console but the script is not writing into a file:

var log4js = require('log4js');
log4js.configure({
  appenders: {
    cleanupLogs: {
      type: 'file',
      filename: 'QuoteCleanup.log'
    },
    console: {
      type: 'console'
    }
  },
  categories: {
    default: {
      appenders: ['console'],
      level: 'trace'
    }
  }
});

var log = log4js.getLogger();
Muhammad Omer Aslam
  • 22,976
  • 9
  • 42
  • 68

1 Answers1

0

You can use this devtools snippet shown below to create a console.save method. It creates a FileBlob from the input, and then automatically downloads it.

Edited I just edited my answer try this one and tell if this works for you

log4js.configure({
  appenders: {
    everything: {
      type: 'file',
      filename: 'QuoteCleanup.log'
    }
  },
  categories: {
    default: {
      appenders: ['everything'],
      level: 'debug'
    }
  }
});

const logger = log4js.getLogger();
logger.debug('I will be logged in QuoteCleanup.log');
Muhammad Omer Aslam
  • 22,976
  • 9
  • 42
  • 68