Logging

OrientDB handles logs using the Java Logging Framework, which is bundled with the JVM. The specific format it uses derives from the OLogFormatter class, which defaults to:

  1. <date> <level> <message> [<requester>]
  • <date> Shows the date of the log entry, using the date format YYYY-MM-DD HH:MM:SS:SSS.
  • <level> Shows the log level.
  • <message> Shows the log message.
  • <class> Shows the Java class that made the entry, (optional).

The supported levels are those contained in the JRE class java.util.logging.Level. From highest to lowest:

  • SEVERE
  • WARNING
  • INFO
  • CONFIG
  • FINE
  • FINER
  • FINEST

By default, OrientDB installs two loggers:

  • console: Logs to the shell or command-prompt that starts the application or the server. You can modify it by setting the log.console.level variable.
  • file: Logs to the log file. You can modify it by setting the log.file.level variable.

Configuration File

You can configure logging strategies and policies by creating a configuration file that follows the Java Logging Messages configuration syntax. For example, consider the following from the orientdb-server-log.properties file:

  1. # Specify the handlers to create in the root logger
  2. # (all loggers are children of the root logger)
  3. # The following creates two handlers
  4. handlers = java.util.logging.ConsoleHandler, java.util.logging.FileHandler
  5. # Set the default logging level for the root logger
  6. .level = ALL
  7. # Set the default logging level for new ConsoleHandler instances
  8. java.util.logging.ConsoleHandler.level = INFO
  9. # Set the default formatter for new ConsoleHandler instances
  10. java.util.logging.ConsoleHandler.formatter = com.orientechnologies.common.log.OLogFormatter
  11. # Set the default logging level for new FileHandler instances
  12. java.util.logging.FileHandler.level = INFO
  13. # Naming style for the output file
  14. java.util.logging.FileHandler.pattern=../log/orient-server.log
  15. # Set the default formatter for new FileHandler instances
  16. java.util.logging.FileHandler.formatter = com.orientechnologies.common.log.OLogFormatter
  17. # Limiting size of output file in bytes:
  18. java.util.logging.FileHandler.limit=10000000
  19. # Number of output files to cycle through, by appending an
  20. # integer to the base file name:
  21. java.util.logging.FileHandler.count=10

When the log properties file is ready, you need to tell the JVM to use t, by setting java.util.logging.config.file system property.

  1. $ java -Djava.util.logging.config.file=mylog.properties

Setting the Log Level

To change the log level without modifying the logging configuration, set the log.console.level and log.file.level system variables. These system variables are accessible both at startup and at runtime.

Configuring Log Level at Startup

You can configure log level at startup through both the orientdb-server-config.xml configuration file and by modifying the JVM before you start the server:

Using the Configuration File

To configure log level from the configuration file, update the following elements in the <properties> section:

  1. <properties>
  2. <entry value="info" name="log.console.level" />
  3. <entry value="fine" name="log.file.level" />
  4. ...
  5. </properties>

Using the JVM

To configure log level from the JVM before starting the server, run the java command to configure the log.console.level and log.file.level variables:

  1. $ java -Dlog.console.level=INFO -Dlog.file.level=FINE

Configuring Log Level at Runtime

You can configure log level at runtime through both the Java API and by executing an HTTP POST against the remote server.

Using Java Code

Through the Java API, you can set the system variables for logging at startup through the System.setProperty() method. For instance,

  1. public void main(String[] args){
  2. System.setProperty("log.console.level", "FINE");
  3. ...
  4. }

Using HTTP POST

Through the HTTP requests, you can update the logging system variables by executing a POST against the URL: /server/log.<type>/<level>.

  • <type> Defines the log type: console or file.
  • <level> Defines the log level.

Examples

The examples below use cURL to execute the HTTP POST commands against the OrientDB server. It uses the server root user and password.

  • Enable the finest tracing level to the console:

    1. $ curl -u root:root -X POST http://localhost:2480/server/log.console/FINEST
  • Enable the finest tracing level to file:

    1. $ curl -u root:root -X POST http://localhost:2480/server/log.file/FINEST

Install Log Formatter

OrientDB Server uses its own log formatter. In order to enable the same for your application, you need to include the following line:

  1. OLogManager.installCustomFormatter();

The Server automatically installs the log formatter. To disable it, use orientdb.installCustomFormatter.

  1. $ java -Dorientdb.installCustomFormatter=false