Skip to content
Rolf Kristensen edited this page Nov 11, 2023 · 22 revisions

PerformanceCounterTarget updates specified Windows Performance Counter on each write.

Platforms Supported: Limited - Windows only and requires nuget-package NLog.PerformanceCounter with NLog 5.0

Configuration Syntax

<targets>
  <target xsi:type="PerfCounter"
          counterName="String"
          categoryName="String"
          instanceName="String"
          counterHelp="String"
          counterType="Enum"
          autoCreate="Boolean"
          incrementValue="Layout"
           />
</targets>

The actual Performance Counter can be created by Installing target, or by using autoCreate="true".

Read more about using the Configuration File.

Parameters

  • counterName - Name of the performance counter. Required.

  • categoryName - Name of the performance counter category. Required.

  • instanceName - Performance counter instance name.

  • counterHelp - Counter help text.

  • counterType - Performance counter type. Default: NumberOfItems32
    Possible values:

    • AverageBase
    • AverageCount64
    • AverageTimer32
    • CounterDelta32
    • CounterDelta64
    • CounterMultiBase
    • CounterMultiTimer
    • CounterMultiTimer100Ns
    • CounterMultiTimer100NsInverse
    • CounterMultiTimerInverse
    • CounterTimer
    • CounterTimerInverse
    • CountPerTimeInterval32
    • CountPerTimeInterval64
    • ElapsedTime
    • NumberOfItems32
    • NumberOfItems64
    • NumberOfItemsHEX32
    • NumberOfItemsHEX64
    • RateOfCountsPerSecond32
    • RateOfCountsPerSecond64
    • RawBase
    • RawFraction
    • SampleBase
    • SampleCounter
    • SampleFraction
    • Timer100Ns
    • Timer100NsInverse
  • autoCreate - Indicates whether performance counter should be automatically created. Default: false.

  • incrementValue - The value by which to increment the counter. Layout. Default: 1.

    Introduced in NLog v4.2

Clone this wiki locally