-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Environment layout renderer
Rolf Kristensen edited this page Mar 15, 2025
·
13 revisions
The environment variable like USERNAME, TMP, USERPROFILE, COMPUTERNAME, PROCESSOR_ARCHITECTURE etc.
Platforms Supported: All
${environment:variable=String}
-
variable - Name of the environment variable. Required. Examples:
USERNAME,TMP,USERPROFILE,COMPUTERNAME,PROCESSOR_ARCHITECTUREetc.
-
For better performance then consider to combine with cached=true. Thus only resolving environment-variable value only once, but then not react to any changes of the environment variable.
-
This Layout Renderer outputs environment variables, and NOT properties from System.Environment
-
To list all environment variables in your system:
- Open Command Prompt (cmd) and execute the command
set - Open PowerShell and execute the command
dir env: - System.Environment.GetEnvironmentVariables()
- Open Command Prompt (cmd) and execute the command
log file for 32 bits systems in folder 32 and otherwise in folder 64
<target
xsi:type="File"
name="file1"
fileName="c:\temp\${when:when='${environment:PROCESSOR_ARCHITECTURE:cached=true}'='X86':inner=32:else=64}\file.log" />- Troubleshooting Guide - See available NLog Targets and Layouts: https://nlog-project.org/config
- Getting started
- How to use structured logging
- Troubleshooting
- FAQ
- Articles about NLog
-
All targets, layouts and layout renderers
Popular: - Using NLog with NLog.config
- Using NLog with appsettings.json