English 中文(简体)
OrientDB Tutorial

OrientDB Database Commands

OrientDB Record Commands

OrientDB Class Commands

OrientDB Cluster Commands

OrientDB Property Commands

OrientDB Vertex Commands

OrientDB Edge Commands

OrientDB Advanced Concepts

OrientDB Interfaces

OrientDB Useful Resources

Selected Reading

OrientDB - Logging
  • 时间:2024-12-27

OrientDB - Logging


Previous Page Next Page  

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 −

    SEVERE (highest value)

    WARNING

    INFO

    CONFIG

    FINE

    FINER

    FINEST (lowest value)

By default, two loggers are installed −

    Console, as the output of the shell/command prompt that starts the apppcation/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’.

Configure Logging

The logging strategies and popcies can be configured using a file following the Java.

syntax − Java Logging configuration.

Example

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.pmit = 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 ... 

Set the logging level

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.

Logging at Startup

Following are the procedures to set logging at startup level in different ways.

In the Server Configuration

Open the file orientdb-server-config.xml and add or update these pnes at the end of the file inside the <properties> section −

<entry value = "fine" name = "log.console.level" /> 
<entry value = "fine" name = "log.file.level" /> 

In Server.sh (or .bat) Script

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 ... 

Logging at Run-time

Following are the procedures to set logging at startup level in different ways.

By Using Java Code

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.

pubpc void main(String[] args){ 
   System.setProperty("log.console.level", "FINE"); 
   ... 
}

On Remote Server

Execute a HTTP POST against the URL: /server/log.<type>/<level>, where −

    <type> can be "console" or "file"

    <level> is one of the supported levels

Example

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 
Advertisements