16.1 Configuring Log4j Logging

The default log4j logging configuration file is located in /etc/oracle/graph/log4j2-server.xml. This configuration file contains the target location for the logs in /var/log/oracle/graph/. Additionally, the rolling file appenders are also defined in this configuration file.

Note:

  • Log4j is configured to roll the log files based on both log size (250 MB) and date.
  • Log files are automatically saved in a compressed format in subdirectories, one directory per month. There can be multiple files on a given day.
  • Also, each startup of the graph server(PGX) triggers a new log file.

The log4j configuration file is picked up automatically by the the graph server(PGX). To use this configuration in your java application, you can set the log4j.configurationFile system variable when launching the JVM:

java -Dlog4j.configurationFile=$PGX_HOME/conf/log4j2.xml ...

Changing Logging Level During a JShell Session

When connected to the graph server using JShell, you can use the loglevel(String loggerName, String levelName) function to quickly change the logging level of any logger. For example:

loglevel("oracle.pgx", "debug")
loglevel("ROOT", "info")
loglevel("org.apache.hadoop", "off")

Changing Slf4j Implementation

You can replace the log4j JARs in $PGX_HOME/third-party with your own slf4j implementation. You must only place your JAR files in $PGX_HOME/third-party and it will get wild-card included when the graph shell client is started.

Logging in a Web Application Server

The graph-server-<version>-pgx<version>.war file in the oracle-graph-webapps-<version>.zip download package contains the log4j2.xml. This file determines what should be logged in the web application running on the application server of your choice. The file is located in the folder WEB-INF/classes inside the graph-server-<version>-pgx<version>.war file. By default, only errors are logged. But you can change this file if you want more logging in your web server. You must restart the web server after you change the file, for the change to take effect.