Logging and Guidewire PolicyCenter

Guidewire PolicyCenter provides a number of ways to configure logging-related parameters.

The log files directory and the View Logs screen

PolicyCenter includes a log viewer on the Server Tools View Logs screen, accessible to administrators. The guidewire.logDirectory property in file log4j2.xml specifies the default location of log files for the PolicyCenter log viewer.

In the base configuration, Guidewire sets this property to the following value:
  • guidewire.logDirectory = /tmp/gwlogs/PolicyCenter/logs/

Guidewire recommends that you set the log file locations for the individual logging appenders to the same directory as that defined in property guidewire.logDirectory. Using the same directory ensures that these log files are visible from the View Logs screen.

Logging and server environments

It is possible specify multiple log4j2.xml files that specify logging configuration for specific server environments. For example, it is possible to specify a logging configuration file for a test environment and a different configuration file for production environments:

  • If the env attribute for a server is non-existent (null), PolicyCenter reads the logging configuration from the default log4j2.xml file.
  • If the env attribute is non-null PolicyCenter tries to obtain the logging configuration from an env-log4j2.xml file that exists in the same directory as the default log4j2.xml file.

For example, if you have an server environment called test, PolicyCenter looks for logging configuration in file test-log4j2.xml. If this file does not exist, then PolicyCenter reads the logging configuration from the default log4j2.xml file.

Configure logging in a multiple instance environment

About this task

In file log4j2.xml, it is possible to use variables to specify log file names and locations. Using variables is particularly useful if there are multiple PolicyCenter instances on the same physical server. You can use a common logging definition file and generate log files for each separate PolicyCenter instance. You do this by defining a serverid system property in config.xml and using the system property in file log4j2.xml.

Procedure

  1. In file config.xml, add an entry to the <registry> element that defines a serverid system property, for example:
    <registry roles="batch, workqueue, scheduler, messaging, startable, ui" >
      <systemproperty default="" name="serverid" value="myserverid" />
    </registry>

    Notice that this code defines a system property, myserverid.

  2. Open file log4j2 for editing.
  3. If it does not already exist, use a Property element to set the default logging directory, for example:
    • <Property name="guidewire.logDirectory">/tmp/gwlogs/PolicyCenter/logs</Property>

    You must use an absolute path to a directory that already exists. You must also use forward slashes as the path separator.

  4. Update the DailyFileLog appender and set the fileName and filePattern attributes by using the system property that you defined in step 1. Use serverid.noroles to suppress the names of the roles associated with each server. Preface the name of the system property with sys:, for example:
    <RollingFile name="DailyFileLog" fileName="${guidewire.logDirectory}/${sys:myserverid.noroles}.log"
          filePattern="${guidewire.logDirectory}/${sys:myserverid.noroles}.log%d{.yyyy-MM-dd}">
      <PatternLayout pattern="${file.defaultPattern}" charset="UTF-8"/>
      <TimeBasedTriggeringPolicy/>
    </RollingFile>
  5. Rebuild and redeploy PolicyCenter to each cluster member.
  6. Start each server by using the system property that sets the environment and server ID values. For example, if using development Jetty servers, use the following commands:
    • gwb runServer -Dgw.passthrough.myserverid=test#batch,messaging,ui
    • gwb runServer -Dgw.passthrough.myserverid=prod#batch, workqueue,scheduler,messaging,ui

    Notice that you must use the Java system property passthrough syntax in starting the application server.

Results

As each servers starts, the server writes a log file to the common log file directory specified by the value of guidewire.logDirectory property. Each log file includes the value of serverid in the log file name. In this example, after starting the two defined servers, the /tmp/gwlogs/PolicyCenter/logs directory contains two log files:

  • test.log
  • prod.log