# Set the severity field

It is possible to configure the `severity` field with the `set-severity()` rewrite function. When configured, the `set-severity()` rewrite function will only rewrite the `$SEVERITY` field in the message to the first parameter value specified in the function.

Note If the parameter value is not a valid parameter value, the function ignores it and sends a debug message, but the AxoSyslog application still sends the message. 

FilterX has no `set_severity()` counterpart. See the related [`set_pri()`](../../../docs/axosyslog-core/4.26/filterx/function-reference/index.md#set-pri) function, which sets the combined PRI value (`facility * 8 + severity`), so you cannot set the severity without also setting the facility. It also takes a number, not a severity name.

## Declaration

Terminal window
```
    rewrite <name_of_the_rule> {
        set-severity("severity string or number");
    };
```

## Parameters

The `set-severity()` rewrite function has a single, mandatory parameter that can be defined as follows:

Terminal window
```
    set-severity( "parameter1" );
```

## Accepted values

The `set-severity()` rewrite function accepts numeric values, named values, and aliases. Aliases are available in AxoSyslog version 4.6 and later.

Numerical Code | Named Value | Alias  
---|---|---  
0 | `emerg` | `SYSLOG_SEVERITY_CODE(0)`  
0 | `emergency` | `SYSLOG_SEVERITY_CODE(0)`  
0 | `panic` | `SYSLOG_SEVERITY_CODE(0)`  
1 | `alert` | `SYSLOG_SEVERITY_CODE(1)`  
2 | `crit` | `SYSLOG_SEVERITY_CODE(2)`  
2 | `critical` | `SYSLOG_SEVERITY_CODE(2)`  
2 | `fatal` | `SYSLOG_SEVERITY_CODE(2)`  
3 | `err` | `SYSLOG_SEVERITY_CODE(3)`  
3 | `error` | `SYSLOG_SEVERITY_CODE(3)`  
4 | `warning` | `SYSLOG_SEVERITY_CODE(4)`  
4 | `warn` | `SYSLOG_SEVERITY_CODE(4)`  
5 | `notice` | `SYSLOG_SEVERITY_CODE(5)`  
6 | `info` | `SYSLOG_SEVERITY_CODE(6)`  
6 | `log` | `SYSLOG_SEVERITY_CODE(6)`  
7 | `debug` | `SYSLOG_SEVERITY_CODE(7)`  
  
## Example usage for the set-severity() rewrite function

The following examples use the `set-severity()` rewrite function.

Using a named value:

Terminal window
```
    rewrite {
        set-severity("info");
    };
```

Using a numeric value:

Terminal window
```
    rewrite {
        set-severity("6");
    };
```

Using a template:

Terminal window
```
    rewrite {
        set-severity("${.json.severity}");
    };
```

## Options

The `set-severity()` rewrite rule has the following option.

## condition()

|   
---|---  
Type: | filter expression  
Default: | N/A  
  
_Description:_ Applies the rewrite rule only to the messages that match the specified filter expression. Messages that don’t match the filter pass through the rule unmodified, and continue to the next element of the log path. You can use any filter expression here, and you can reference an existing filter with the `filter()` function. For details, see [Conditional rewrites](../../../docs/axosyslog-core/4.26/chapter-manipulating-messages/modifying-messages/conditional-rewrite/index.md).

Last modified August 10, 2026: [Sync rewrite rule options with the source (d33662b7)](<https://github.com/axoflow/axosyslog-core-docs/commit/d33662b7e6212a930666d724aa0ba2f88d4ba4ae>)