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 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:
    log4j.rootLogger = INFO, LOGFILE
    log4j.appender.LOGFILE = org.apache.log4j.FileAppender
    log4j.appender.LOGFILE.file = log_url/log_filename.log
    log4j.appender.LOGFILE.layout = org.apache.log4j.PatternLayout
    log4j.appender.LOGFILE.layout.ConversionPattern = %-4r %5p %c - %m - %X{requestingUserName}%n

    Where log_url is the location and log_filename is the name of the log file.

    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, see Class PatternLayout in the Apache log4j documentation.

  2. Open the $GREDIR/bin/greportwriter.bat file. To the java command, add the following option:
    exec java -Dlog4j.configuration=config_url/config_filename -Djava.awt.headless=true GReportWriter $DEBUGOPTION "$@"

    Where config_url is the location and config_filename is the name of the text file you created in step 1. For example:

    exec java 
    -Dlog4j.configuration="file:///home/alex/log4j_configuration.txt" 
    -Djava.awt.headless=true GReportWriter $DEBUGOPTION "$@"

GRE logs are written to the log_url/log_filename.log file.

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 one of the configuration files that are shipped inside gre.jar. These files are dependent on the operating system:

  • Unix: log4j_configuration_unx_d.txt
  • Windows: log4j_configuration_win_d.txt
  • Other: log4j_configuration_oth_d.txt

For example, in Linux™:

exec java 
-Dlog4j.configuration="com/fourjs/report/resources/log4j_configuration_unx_d.txt" 
-Djava.awt.headless=true GReportWriter $DEBUGOPTION "$@"