OrientDB uses the Java Logging framework bundled with Java Virtual Machine. OrientDB's default log format is managed by OLogFormatter class.
The following statement is the basic syntax of logging command.
<date> <level> <message> [<requester>]
Following are the details about the options in the above syntax.
<date> − It is the log date in the following format: yyyy-MM-dd HH:mm:ss:SSS.
<level> − It is the logging level as 5 chars output.
<message> − It is the text of log, it can be of any size.
[<class>] − It is the Java class that is logged (optional).
Supported levels are those contained in the JRE class java.util.logging.Level. They are −
By default, two loggers are installed −
Console, as the output of the shell/command prompt that starts the application/server. Can be changed by setting the variable ‘log.console.level’.
File, as the output to the log files. Can be changed by setting the ‘log.file.level’.
The logging strategies and policies can be configured using a file following the Java.
syntax − Java Logging configuration.
Copy the following content from orientdb-server-log.properties file and put it in the $ORIENTDB_HOME/config file.
# Specify the handlers to create in the root logger # (all loggers are children of the root logger) # The following creates two handlers handlers = java.util.logging.ConsoleHandler, java.util.logging.FileHandler # Set the default logging level for the root logger .level = ALL # Set the default logging level for new ConsoleHandler instances java.util.logging.ConsoleHandler.level = INFO # Set the default formatter for new ConsoleHandler instances java.util.logging.ConsoleHandler.formatter = com.orientechnologies.common.log.OLogFormatter # Set the default logging level for new FileHandler instances java.util.logging.FileHandler.level = INFO # Naming style for the output file java.util.logging.FileHandler.pattern =../log/orient-server.log # Set the default formatter for new FileHandler instances java.util.logging.FileHandler.formatter = com.orientechnologies.common.log.OLogFormatter # Limiting size of output file in bytes: java.util.logging.FileHandler.limit = 10000000 # Number of output files to cycle through, by appending an # integer to the base file name: java.util.logging.FileHandler.count = 10
To tell the JVM where the properties file is placed, you need to set the "java.util.logging.config.file" system property to it. For example, use the following command −
$ java -Djava.util.logging.config.file=mylog.properties ...
To change the logging level without modifying the logging configuration, just set the "log.console.level" and "log.file.level" system variables to the requested levels.
Following are the procedures to set logging at startup level in different ways.
Open the file orientdb-server-config.xml and add or update these lines at the end of the file inside the <properties> section −
<entry value = "fine" name = "log.console.level" /> <entry value = "fine" name = "log.file.level" />
Set the system property "log.console.level" and "log.file.level" to the levels you want using the -D parameter of java.
$ java -Dlog.console.level = FINE ...
Following are the procedures to set logging at startup level in different ways.
The system variable can be set at startup using the System.setProperty() API. The following code snippet is the syntax to set logging level using Java code.
public void main(String[] args){ System.setProperty("log.console.level", "FINE"); ... }
Execute a HTTP POST against the URL: /server/log.<type>/<level>, where −
The following example uses cURL to execute a HTTP POST command against OrientDB Server. Server's "root" user and password were used, replace with your own password.
Enable the finest tracing level to console −
curl -u root:root -X POST http://localhost:2480/server/log.console/FINEST
Enable the finest tracing level to file −
curl -u root:root -X POST http://localhost:2480/server/log.file/FINEST