Configure custom logs

By configuring custom logs, we can determine what data to capture in the logs and how to display the logged data. We can configure custom logs using wsadmin, through rule set administrative tasks, or using the script.

With custom logging, the on demand router (ODR) records customized entries to log files based on defined conditions. For each request, the ODR evaluates the rule conditions. For each fulfilled condition, the ODR logs an entry in the custom log file. For example, a specific URL or a specific virtual host name.

Validation is limited to type checking. Thorough validation is performed during the ODR startup. Problems are reported through runtime exceptions recorded in the SystemOut log file.

  1. Create a rule set:

      wsadmin>$AdminTask createRuleset {-odrname odr1 -nodename myNode01 -rulesetName myRuleset -rulesetType HTTP -defaultContinue true}

  2. Add a rule to the rule set created, with the expression set to match when the virtual host is NOT badvhost.

      wsadmin>$AdminTask addRuleToRuleset {-odrname odr1 -nodename myNode01 -rulesetName myRuleset -ruleName myRule -rulePriority 0 -expression "virtualhost <> 'badvhost'"}

  3. Add a custom log action. Note the @ symbol used in the actionValue argument. The following example shows wsadmin for listing the configurable attributes for the action and the results:

      wsadmin>$AdminTask addActionToRule {-odrname odr1 -nodename myNode01 -rulesetName myRuleset -ruleName myRule -actionName myCustomLogAction -actionType log -actionValue "Custom1.log %r %B %h %z %Z@Custom2.log %t %r %s" -actionContinue true}

  4. Save the changes.

      wsadmin>$AdminConfig save


Two examples of custom log outputs follow. These examples are based on the formats specified in the previous actions, after running several HTTP requests.

"GET /BADAPP HTTP/1.1" 70 - -
"GET /A/ServerInfo HTTP/1.1" 422 myCell01/myNode01/MyClusterA_myNode01
"GET /A/ServerInfo HTTP/1.1" 90 - -
"GET /favicon.ico HTTP/1.1" 70 - -
"GET /favicon.ico HTTP/1.1" 70 - -
"GET /A/ServerInfo HTTP/1.1" 422 myCell01/myNode01/MyClusterA_myNode01
"GET /A/ServerInfo HTTP/1.1" 422 myCell01/myNode01/MyClusterA_myNode01
01/Jul/2009:20:35:35 EDT "GET /BADAPP HTTP/1.1" 404
01/Jul/2009:20:35:43 EDT "GET /A/ServerInfo HTTP/1.1" 200
01/Jul/2009:20:37:21 EDT "GET /A/ServerInfo HTTP/1.1" 503
01/Jul/2009:20:37:21 EDT "GET /favicon.ico HTTP/1.1" 404
01/Jul/2009:20:37:24 EDT "GET /favicon.ico HTTP/1.1" 404
01/Jul/2009:20:42:55 EDT "GET /A/ServerInfo HTTP/1.1" 200
01/Jul/2009:20:42:59 EDT "GET /A/ServerInfo HTTP/1.1" 200


Related concepts

  • Custom log file format

  • Ruleset administrative tasks
  • script
  • Intelligent Management: HTTP operands