Logging
This guide describes how to configure JxBrowser logging.
The root cause of many issues can be detected by analyzing JxBrowser log messages.
If you see an issue or some unexpected behavior, please configure JxBrowser to print all log messages to
a file or System.err
, reproduce the issue, and provide us with the collected
log messages.
By default, JxBrowser is configured to print all log messages with the ERROR
level to System.err
.
Levels
JxBrowser supports the following logging levels: DEBUG
< INFO
< WARNING
< ERROR
. By default, the library prints
only messages with ERROR
logging level, the rest is ignored.
Use OFF
level to turn off logging completely, and ALL
level to log all the messages.
You can change the default logging level via jxbrowser.logging.level
system property or JxBrowser Logging API.
Example: Setting Logging Level
Use the following system property to enable DEBUG
logging:
-Djxbrowser.logging.level=DEBUG
Or configure it in the code:
System.setProperty("jxbrowser.logging.level", "DEBUG");
System.setProperty("jxbrowser.logging.level", "DEBUG")
Or use JxBrowser Logging API:
import com.teamdev.jxbrowser.logging.Level;
import com.teamdev.jxbrowser.logging.Logger;
...
Logger.level(Level.DEBUG);
import com.teamdev.jxbrowser.logging.Level
import com.teamdev.jxbrowser.logging.Logger
...
Logger.level(Level.DEBUG)
Logging to a file
To print all log messages to a file please use the jxbrowser.logging.file
system property.
Use the following system property to configure the log file path:
-Djxbrowser.logging.file=jxbrowser.log
Or configure it in the code:
System.setProperty("jxbrowser.logging.file", "jxbrowser.log");
System.setProperty("jxbrowser.logging.file", "jxbrowser.log")
The value of the property may be both an absolute or relative path to a file.
If the library can’t create a log file, it fallbacks to the default behavior and prints an error message
with the exception stack trace to System.err
.