A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/NLog/NLog/wiki/Replace-Layout-Renderer below:

Replace Layout Renderer · NLog/NLog Wiki · GitHub

Replaces a string in the output of another layout with another string.

Platforms Supported: All

${replace:searchFor=String:wholeWords=Boolean:replaceWith=String
         :ignoreCase=Boolean:inner=Layout}

NLog v6 does not support Regular Expressions (RegEx), and have removed these options:

If needing Regular Expressions, then one can use ${regex-replace} from NLog.RegEx-nuget-package.

Replace sensitive data, that starts with password= or password:

<variable name="replacePasswords"
  value="${replace:inner=${message}:searchFor=(?i)(?&lt;=password[=\:])(.*?)(?=(\;|$| )):replaceWith=******:regex=true}" />

Truncate after token, search for , and replace everything after with empty string:

<variable name="truncateAfterComma"
  value="${replace:inner=${aspnet-request-ip}:searchFor=,.*:replaceWith=:regex=true}" />

With Regular Expressions keep in mind the content escaping rules to escape special characters in Regex. Specifically } and \. So for example the regular expression (\d{3})+ would need to be escaped like so in your configuration

<variable name="messageNoDigits" 
  value="${replace:inner=${message}:searchFor=(\\d{3\})+:replaceWith=:regex=true}" />

There is a dedicated layout ${replace-newlines} for replacing / removing newlines (handles both Unix and Windows newlines)


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4