Custom Exit Codes and Regular Expression Pattern Matching against Logs


By default, a Job that completes will have an exit code of 0 and a Final Severity of “Success”. If a Job completes with any other exit code, it has a Final Severity of “Error”.

If your scripts set different exit codes, JAMS can recognize a custom set of exit code values or regular expression patterns in the output of a Job. This pattern matching feature can be used to return Success or Error for that Job. This is also useful if you need to override the Final Severity based on the content in the Job Log File. To do this, follow the steps in the section below for creating custom Execution Method.

Using Good and Bad Regular Expression Patterns

You can add good and bad regular expression patterns to an Execution Method. If both patterns were added and JAMS does not find a pattern in the Job Log file, the Job completes with a Final Severity of “Warning”. If both patterns were added and JAMS finds a bad pattern, the Job completes with a Final Severity of “Error”.

Specifying Custom Exit Codes and Regular Expression Patterns

You have a few options for which exit codes to use. You can fill in the appropriate values and separate them with commas, if you have multiple custom code values. Follow the steps below for an existing Job or custom Execution Method.

Standard Microsoft .NET regular expression language can be used for the GoodRegex and BadRegex handling. 

Creating a Custom Execution Method

  1. Click Execution Methods from the Shortcuts menu.
  2. Click +.
  3. In the Name field, enter a name for this Execution Method.
  4. In the Base Method field, select an existing Execution Method.
  5. Click Ok.
  6. Click the Properties tab.
  7. For Good Regex patterns, ensure MessageCode is selected from the Exit Code Handling field.
    If the specified pattern is not detected within the Log File tab in the Monitor Entry, the Final Severity of the Entry is set to Warning. If the specified pattern is detected within the Log File tab, the Final Severity is set to Success. 
  8. For Bad Regex patterns, the normal integer-based Exit Code Handling, such as ZeroIsGood or OneIsGood, can be retained.

    NOTE: The Final Severity will be overridden to Error if a Bad Regex Pattern match is detected regardless of the Exit Code returned by the process.

  9. Click Save and Close
Have more questions? Submit a request


  • Avatar
    Christophe Lauliac

    I've got a little question about that : could you give some samples about using this in a job?
    We will have some different kind jobs (SSIS, Exe, Api invoke method) that should return specific error message code.
    I'd like that all the return codes of my jobs for different kind of execution should be catched by jams.
    How can do that easily?
    Could you provide some samples?

  • Avatar
    Gennaro Piccolo

    Hello Christophe, each execution method has to be configured individually in this way to capture a message and return success or failure in a job. By default, we use 0 as the success code for all execution methods. You would need to configure a new execution method and modify it using the instructions above to capture the message code you want to consider as success or failure.

  • Avatar
    Daniel Williams

    How do I make these options appear in the first place? I've taken over an environment and some of my jobs have these options, some don't. Same execution method.

  • Avatar
    Gennaro Piccolo

    Hello Daniel, if you want to control these at the execution method level, you can click on the Job Properties tab, and then click on the Add Property button.