CARVIEW |
Select Language
HTTP/2 200
date: Wed, 23 Jul 2025 15:30:53 GMT
content-type: text/html; charset=utf-8
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With,Accept-Encoding, Accept, X-Requested-With
x-robots-tag: none
etag: W/"ff14003fa53f427d6dd72e922c9dd9fe"
cache-control: max-age=0, private, must-revalidate
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: no-referrer-when-downgrade
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
server: github.com
content-encoding: gzip
accept-ranges: bytes
set-cookie: _gh_sess=0CSFtDdxU%2B37zJjJqgw9BTwU2szV4wPswBCec%2FHcTGLpZAoyGx9l1UWRqjP%2FlwKkDt3HVtySj620393ffwHlUMIUq0hF%2F%2FKS5Cli5KE9gRXpUaDLh%2Bb9lNO8zvDEkh1K71%2BHam%2FDZizPjIeg%2FMe7flfJrvHdj%2B2azybqBupt%2BIMLTyvBv2vtAsjMeJCSqF%2FucSzNVpC1pi6%2BjQ6C7HR%2BAkuL1%2B2YGHPoM5p1EfrBLxcPRssk8isig5nNS5QZSqEj9vrWL63CldWRoT%2BqupfeyQ%3D%3D--Pz96rfuTd6ciQwaQ--f6ybQAkFfR5DUxefXmd%2FmA%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax
set-cookie: _octo=GH1.1.359962082.1753284653; Path=/; Domain=github.com; Expires=Thu, 23 Jul 2026 15:30:53 GMT; Secure; SameSite=Lax
set-cookie: logged_in=no; Path=/; Domain=github.com; Expires=Thu, 23 Jul 2026 15:30:53 GMT; HttpOnly; Secure; SameSite=Lax
x-github-request-id: C91A:35B563:DEE8CF:1079C5A:6881002D
NLog config Example · NLog/NLog Wiki · GitHub
Skip to content
Navigation Menu
{{ message }}
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
NLog config Example
Rolf Kristensen edited this page May 31, 2025
·
14 revisions
Save this file as "nlog.config" in the root of your application (Add to project with Copy if newer
)
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="https://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://www.nlog-project.org/schemas/NLog.xsd NLog.xsd">
autoReload="carview.php?tsp=true"
internalLogLevel="Warn"
internalLogFile="${basedir}/nlog-internal.txt">
<variable name="defaultLayout" value="${longdate}|${level}|${message:withException=true}" />
<targets>
<target name="logfile" xsi:type="File" fileName="file.txt" layout="${defaultLayout}" />
<target name="console" xsi:type="ColoredConsole" layout="${defaultLayout}" />
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="logfile" />
<logger name="*" minlevel="Info" writeTo="console" />
</rules>
</nlog>
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="https://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://www.nlog-project.org/schemas/NLog.xsd NLog.xsd">
autoReload="carview.php?tsp=true"
internalLogLevel="Warn"
internalLogFile="${basedir}/logs/nlog-internal.txt">
<variable name="gmailUsername" value="${trim-whitespace:${file-contents:${basedir}/gmailusername.txt}}" />
<variable name="gmailPassword" value="${trim-whitespace:${file-contents:${basedir}/gmailpassword.txt}}" />
<extensions>
<!-- load NLog.Web to enable ASP.NET-specific functionality -->
<add assembly="NLog.Web" />
</extensions>
<!-- define various log targets -->
<targets>
<!-- write logs to file -->
<target xsi:type="File" name="file" fileName="${basedir}/logs/${shortdate}.log"
layout="${longdate} ${aspnet-request:servervariable=URL} ${uppercase:${level}} ${message}" />
<!-- write log message to database -->
<target xsi:type="Database" name="db">
<!-- SQL command to be executed for each entry -->
<commandText>INSERT INTO [LogEntries](TimeStamp, Message, Level, Logger) VALUES(getutcdate(), @msg, @level, @logger)</commandText>
<!-- parameters for the command -->
<parameter name="@msg" layout="${message}" />
<parameter name="@level" layout="${level}" />
<parameter name="@logger" layout="${logger}" />
<!-- connection string -->
<dbProvider>System.Data.SqlClient</dbProvider>
<connectionString>server=.\SQLEXPRESS;database=MyLogs;integrated security=sspi</connectionString>
<!-- commands to install database -->
<install-command>
<text>CREATE DATABASE MyLogs</text>
<connectionString>server=.\SQLEXPRESS;database=master;integrated security=sspi</connectionString>
<ignoreFailures>true</ignoreFailures>
</install-command>
<install-command>
<text>
CREATE TABLE LogEntries(
id int primary key not null identity(1,1),
TimeStamp datetime2,
Message nvarchar(max),
level nvarchar(10),
logger nvarchar(128))
</text>
</install-command>
<!-- commands to uninstall database -->
<uninstall-command>
<text>DROP DATABASE MyLogs</text>
<connectionString>server=.\SQLEXPRESS;database=master;integrated security=sspi</connectionString>
<ignoreFailures>true</ignoreFailures>
</uninstall-command>
</target>
<!-- log message to event log -->
<target xsi:type="EventLog" name="eventLog" source="NLog Demo"
layout="${message}${newline}Call site: ${callsite:className=true:methodName=true}${newline}Logger: ${logger}">
</target>
<!-- increase the performance counter -->
<target xsi:type="PerfCounter" name="pc1" categoryName="My Log" counterName="My Counter">
</target>
<!-- send mail through GMail server -->
<target xsi:type="Mail"
name="mail"
smtpServer="smtp.gmail.com"
smtpPort="587"
enableSsl="true"
smtpAuthentication="Basic"
smtpUserName="${gmailUsername}"
smtpPassword="${gmailPassword}"
from="${gmailUsername}"
to="${gmailUsername}"
subject="NLogDemo logs"
addNewLines="true"
/>
<!-- send mail asynchronously, so that it does not block the calling thread -->
<wrapper-target xsi:type="AsyncWrapper" name="asyncMail">
<target-ref name="mail"/>
</wrapper-target>
<wrapper-target xsi:type="AspNetBufferingWrapper" name="allOutputs">
<wrapper-target xsi:type="PostFilteringWrapper">
<compound-target xsi:type="SplitGroup">
<target-ref name="file" />
<target-ref name="db" />
<target-ref name="eventLog" />
<target-ref name="pc1" />
<target-ref name="asyncMail" />
</compound-target>
<!-- during normal execution only log Info messages -->
<defaultFilter>level >= LogLevel.Info</defaultFilter>
<!-- if there is at least one error, log everything from trace level -->
<when exists="level >= LogLevel.Error" filter="level >= LogLevel.Trace" />
</wrapper-target>
</wrapper-target>
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo="allOutputs" />
</rules>
</nlog>
- 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
Clone this wiki locally
You can’t perform that action at this time.