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 text 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 file path is the location the gre.log is 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 file as log4j2.xml.
  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 LOG_METHOD placeholder with the path to the log4j2 configuration file created earlier.
    On Windows, replace:
    java -Djava.awt.headless=true %LOG_METHOD% com.fourjs.report.main.GReportWriter %*
    with:
    java -Djava.awt.headless=true -Dlog4j.configurationFile="file:///C:\path-to-log4j2.xml" GReportWriter %*
    On other operating systems such as Linux®/UNIX®, use the file path standard of that operating system; for example:
    java -Djava.awt.headless=true -Dlog4j.configurationFile="file:///home/user/log4j2.xml" GReportWriter %*
  6. Save your changes.

GRE logs are written to the file specified by full-path-to-log-file in step 1.

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.