Non-JavaScript SDKs
Newer versions of the Applitools Eyes SDKs that are not implemented in JavaScript automatically log verbose messages to a file in your TEMP directory within a folder named applitools-logs.
On MacOS and Unix/Linux operating systems, you can find them in:
$TMPDIR/applitools-logs/
On Windows operating systems, you can find them in:
$env:TEMP/applitools-logs/
You can change the directory into which the SDK writes its log files by setting the APPLITOOLS_LOG_DIR environment variable:
APPLITOOLS_LOG_DIR=/path/to/your/logs/
JavaScript SDKs
JavaScript SDKs generally do NOT automatically write log messages to a file. You must configure them to log messages either to the application console or to a file on your system.
The APPLITOOLS_SHOW_LOGS Environment Variable
Setting the APPLITOOLS_SHOW_LOGS environment variable will configure most JavaScript based SDKs will log verbose messages to the console.
APPLITOOLS_SHOW_LOGS=true
Global Logging Configurations
The WebDriverIO and Cypress JavaScript-based SDKs allow you to set a global configuration value to enable verbose logging.
WebDriverIO JavaScript Global enableEyesLogs Configuration
You can enable verbose logs globally by setting enableEyesLogs to true in your wdio.conf.js file.
exports.config = {
// ...
enableEyesLogs: true,
// ...
}
Cypress Global showLogs Configuration
You can enable verbose logs globally by setting showLogs to true in your applitools.config.js file.
module.exports = {
// ...
showLogs: true,
// ...
}
Storybook Global showLogs Configuration
You can enable verbose logs globally by setting showLogs to true in your applitools.config.js file.
module.exports = {
// ...
showLogs: true,
// ...
}
ConsoleLogHandler and FileLogHandler
You can enable verbose logging in almost all JavaScript SDKs by passing a LogHandler implementation to the Eyes object's setLogHandler method.
First, remember to import the ConsoleLogHandler and/or FileLogHandler classes.
Import syntax for the SDKs that support this option are included below.
To log messages to the system console, pass a ConsoleLogHandler instance to the setLogHandler method.
eyes.setLogHandler(new ConsoleLogHandler(isVerbose));
- Pass true as the first parameter for verbose logs. Default is false.
To log messages to a file in the test execution machine's filesystem, pass a FileLogHandler instance to the setLogHandler method.
eyes.setLogHandler(new FileLogHandler(isVerbose, '/path/to/logfile.log', appendToFile));
- Pass true as the first parameter for verbose logs. Default is false.
- Pass a path relative to the current working directory to the log file as the second parameter. Default is eyes.log in the current working directory.
- Pass true as the third parameter to append leg messages for each run to the end of an existing log file, or false overwrite the log file each time you run your tests. Default is true.
Importing Eyes Selenium JavaScript LogHandlers
Import the ConsoleLogHandler and/or FileLogHandler classes.
const { Eyes, ConsoleLogHandler, FileLogHandler } = require("@applitools/eyes-selenium")
Importing Eyes WebDriverIO JavaScript LogHandlers
Import the ConsoleLogHandler and/or FileLogHandler classes.
const { Eyes, ConsoleLogHandler, FileLogHandler } = require("@applitools/eyes-webdriverio")
Importing Eyes Playwright JavaScript LogHandlers
Import the ConsoleLogHandler and/or FileLogHandler classes.
import {Eyes, ConsoleLogHandler, FileLogHandler} from '@applitools/eyes-playwright'
Importing Eyes Puppeteer JavaScript LogHandlers
Import the ConsoleLogHandler and/or FileLogHandler classes.
import {Eyes, ConsoleLogHandler, FileLogHandler} from '@applitools/eyes-puppeteer'
The examples below are out-of-date, and do not apply to most newer versions of the Applitools Eyes SDKs. Please refer to the Applitools API reference guide to find updated documentation for your SDK.
Java (only for Java3 SDKs!) :
Print logs to console:
eyes.setLogHandler(new StdoutLogHandler(true));
Export logs to file:
eyes.setLogHandler(new FileLogger("path/to/file.log",true,true));
.Net:
Print logs to console:
eyes.SetLogHandler(new StdoutLogHandler(true));
eyes.SetLogHandler(new FileLogHandler("path/to/file.log",true,true));
Python: Print logs to console:
from applitools.common import logger, StdoutLogger
import logging
logger.set_logger(StdoutLogger(level=logging.DEBUG))
Export logs to file:
from applitools.common import logger, FileLogger
logger.set_logger(FileLogger("path/to/file.log"))
Ruby:Print logs to console:
require 'logger'
eyes.log_handler = Logger.new(STDOUT)
Export logs to file:
eyes.log_handler = Logger.new('path/to/logfile.log')
JavaScript-Selenium:
Print logs to console:
const { ConsoleLogHandler } = require ('@applitools/eyes-selenium')
eyes.setLogHandler(new ConsoleLogHandler(true));
Export logs to file:
const { FileLogHandler } = require('@applitools/eyes-selenium');
eyes.setLogHandler(new FileLogHandler(true));
Note: The eyes.log file will appear under the root folder.
WebdriverIO 4 & 5:
Print logs to console:
const { ConsoleLogHandler } = require ('@applitools/eyes-webdriverio')
eyes.setLogHandler(new ConsoleLogHandler(true));
Export logs to file:
const { FileLogHandler } = require('@applitools/eyes-webdriverio');
eyes.setLogHandler(new FileLogHandler(true));
Note: The eyes.log file will appear under the root folder.
WebdriverIO 5 Service:
In wdio config file, add:
beforeSession: function (config, capabilities, specs) {
config.enableEyesLogs = true;
},
Espresso:
Print logs to Logcat:
import com.applitools.eyes.android.common.logger.LogHandler;
import com.applitools.eyes.android.common.logger.StdoutLogHandler;
LogHandler mLogHandler = new StdoutLogHandler(true);
eyes.setLogHandler(mLogHandler);
Storybook:
Export logs by defining the following environment variables:
Mac:
export APPLITOOLS_SHOW_LOGS=true && export APPLITOOLS_LOG_DIR=/path/to/your/log/directory
Windows:
set APPLITOOLS_SHOW_LOGS=true
set APPLITOOLS_LOG_DIR=C:\path\to\your\log\directory
Cypress:
Export logs by defining the following environment variables:
Mac:
export APPLITOOLS_SHOW_LOGS=true && export APPLITOOLS_LOG_DIR=/path/to/your/log/directory
Windows:
set APPLITOOLS_SHOW_LOGS=true
set APPLITOOLS_LOG_DIR=C:\path\to\your\log\directory
In the applitools.config.js file add:
showLogs: true
testCafe:
In the applitools.config.js file add:
showLogs: true
Playwright:
Print logs to console:
eyes.setLogHandler(new ConsoleLogHandler(true));