Redirect GRE log messages to a file

Specify a log file to capture the GRE debug messages.

About this task

The GREDEBUG environment variable defines the level of detail to be gathered. By default, in non-distributed mode, the requested debug details are written to standard error. In distributed mode, these details are logged to the gre.log file in the home directory of the user invoking the GRE daemon (see Setting up local distributed mode and Setting up remote distributed mode).

This procedure shows you how to override the default behavior and redirect the debug messages to a specified log file.

Important:

Sensitive and personal data may be written to the output. Make sure that the log output is written to files that can only be read by application administrators.

  1. Create a new XML file with the following entries:
    <?xml version="1.0" encoding="UTF-8"?>
    <Configuration xmlns="http://jakarta.apache.org/log4j/">
      <Appenders>
        <Select>
          <DefaultArbiter>
            <File name="APPENDER" fileName="full-path-to-log-file">
              <PatternLayout pattern="%d{dd MMM yyyy HH:mm:ss,SSS} %5p %c - %m - %X{requestingUserName}%n"/>
            </File>
          </DefaultArbiter>
        </Select>
      </Appenders>
      <Loggers>
        <Root level="info">
          <AppenderRef ref="APPENDER"/>
        </Root>
      </Loggers>
    </Configuration>

    Where full-path-to-log-file is the file path where the .log file will be created.

    Note:

    The conversion pattern determines how logging events are formatted in the file, and is based on the PatternLayout class. You can use other specifiers, for example, %d{ISO8601} to add the date in ISO8601 format. For further information, go to Class PatternLayout in the Apache log4j documentation.

  2. Save the XML file.
  3. Ensure GREDEBUG is set to 3 or higher.
    In most cases, this can be accomplished by selecting the Debug environment set from the Genero Configuration Management dialog.
  4. Open the Genero Report Writer startup script.
    • On a Windows® device, open the $GREDIR/bin/greportwriter.bat file.
    • On a non-Windows device, open the $GREDIR/bin/greportwriter.sh file.
  5. Replace the LOG4J_CONFIGURATION placeholder with the path to the XML configuration file created earlier.
    On Windows, replace:
    java -Djava.awt.headless=true %LOG4J_CONFIGURATION% GReportWriter %*
    with:
    java -Djava.awt.headless=true -Dlog4j.configurationFile="file:///<full_path_to_XML_configFile>" GReportWriter %*
    On other operating systems such as Linux®/UNIX®, use the file path standard of that operating system; for example, replace:
    if [ "$platform" = "Darwin" ] ; then
      exec java "-Djava.library.path=$GREDIR/lib" -Djava.awt.headless=true $LOG4J_CONFIGURATION com.fourjs.report.main.GReportWriter "$@"
    else
      exec java -Djava.awt.headless=true $LOG4J_CONFIGURATION com.fourjs.report.main.GReportWriter "$@"
    fi
    with:
    if [ "$platform" = "Darwin" ] ; then
      exec java "-Djava.library.path=$GREDIR/lib" -Djava.awt.headless=true -Dlog4j.configurationFile="file://<full_path_to_XML_configFile>" com.fourjs.report.main.GReportWriter "$@"
    else
      exec java -Djava.awt.headless=true -Dlog4j.configurationFile="file://<full_path_to_XML_configFile>" com.fourjs.report.main.GReportWriter "$@"
    fi
    <full_path_to_XML_configFile> is the full filepath to the XML configuration file created in step 1.
  6. Save your changes.

Once the GRE daemon is started, the .log file is created in the specified directory. GRE logs are written to the XML file specified.

Note:

If you want to have the same type of logging in non-distributed mode as in distributed mode, it is not necessary to specify an external file. You can instead specify a resource path to the log4j2.xml that is shipped inside gre.jar.