Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/NLogPublic

AppSetting Layout Renderer

Rolf Kristensen edited this pageApr 26, 2024 ·17 revisions

Value from the App Settings configuration (app.config / web.config)

Platforms Supported:Limited (.NET Framework only, when using .NET Core then${configsetting} can be used to read values fromappsettings.json-file)

Introduced with NLog 3.0 and with NLog 4.6+ it was included in default NLog-package without needingNLog.Extended.

Configuration Syntax

${appsetting:item=String:default=String}

Parameters

Rendering Options

  • item - Key in the apps setting. Required

    Introduced with NLog v4.5, and replaces theName-option.

  • Default - Default value if not present. Optional.

Example AppSettings

Example .config

<configuration>  <appSettings>    <addkey="MyKey"value="MyApplication" />  </appSettings></configuration>

Example renderer: producesMyApplication is this case:

${appsetting:item=MyKey:default=mydefault}

Example#2 renderer: producesmydefault is this case:

${appsetting:item=MyKey2:default=mydefault}

Example ConnectionStrings

Introduced with NLog 4.6.5

<configuration>  <appSettings>    <addkey="MyKey"value="MyApplication" />  </appSettings>  <connectionStrings>    <addname="ElasticUrl"connectionString="http://localhost:9200"/>  </connectionStrings></configuration>

Example#3 renderer: produceshttp://localhost:9200 is this case:

${appsetting:item=connectionStrings.ElasticUrl}

Note remember to uninstall/removeNLog.Extended-nuget-package from the application when having upgraded to NLog v4.6.5, else connectionStrings-lookup will not work.

-Troubleshooting Guide - See available NLog Targets and Layouts:https://nlog-project.org/config

Configuration

Programmatic Configuration

Advanced

Extending NLog

Clone this wiki locally


[8]ページ先頭

©2009-2025 Movatter.jp