# Rename message fields

If you want to change the name of a field of a message, you can use `rename()` rewrite rules. This can be also achieved via using `set()` and `unset()` but those require extra conditions and two operation instead of one.

The `rename()` rewrite rule uses positional arguments and they are both required. It supports condition rewrite. For more information, see [Conditional rewrites](../../../docs/axosyslog-core/chapter-manipulating-messages/modifying-messages/conditional-rewrite/index.md).

## Declaration
```
    rewrite r_rewrite_rename {
        rename("<string1>" "<string2>");
    };
    
```

## Example usage for the rename() rewrite function

The following example renames the `.app.name` into `.container` if the `.app.name` exists. Otherwise, it does nothing.
```
 
    rewrite r_rewrite_rename {
        rename(".app.name" ".container");
    };
    
```

Last modified April 9, 2025: [Rewrite-related formatting fixes and title shortenings (07c928a3)](<https://github.com/axoflow/axosyslog-core-docs/commit/07c928a36247e7d98c8d00726187c3afdbc96875>)