Log files are very important while creating automation test suites. It helps you by providing each and exact information about your steps.
In coding language like JAVA you can use Log4j, similar to that, you can use Log4js to generate log files in Javascript and in your Protractor tests.
First you need to install Log4js which can be done using the following command
Now you just need to add following command to to use Log4js API:
You need to configure you Log4js, which can be done like following:
You can use the following to make entries in the log files:
In coding language like JAVA you can use Log4j, similar to that, you can use Log4js to generate log files in Javascript and in your Protractor tests.
First you need to install Log4js which can be done using the following command
npm install -g log4js
Now you just need to add following command to to use Log4js API:
var log4js = require('log4js'); var logger = log4js.getLogger();
You need to configure you Log4js, which can be done like following:
{ "appenders": [ { "type": "file", "filename": "relative/path/to/log_file.log", "maxLogSize": 20480, "backups": 3, "category": "relative-logger" } ] }
You can use the following to make entries in the log files:
logger.trace('Entering cheese testing'); logger.debug('Got cheese.'); logger.info('Cheese is Gouda.'); logger.warn('Cheese is quite smelly.'); logger.error('Cheese is too ripe!'); logger.fatal('Cheese was breeding ground for listeria.');