Click or drag to resize
ResettableFileTarget Class
A NLog FileTarget implementation that will reset/truncate the log file whenever it sees the DeleteToken in a log message.
Inheritance Hierarchy
SystemObject
  Target
    TargetWithLayout
      TargetWithLayoutHeaderAndFooter
        FileTarget
          BlackBerry.Workspaces.NlogExtensionsResettableFileTarget

Namespace:  BlackBerry.Workspaces.NlogExtensions
Assembly:  BlackBerryWorkspacesSDK (in BlackBerryWorkspacesSDK.dll) Version: 7.0.0.223 (7.0.0.223)
Syntax
C#
public class ResettableFileTarget : FileTarget

The ResettableFileTarget type exposes the following members.

Constructors
  NameDescription
Public methodResettableFileTarget
Initializes a new instance of the ResettableFileTarget class
Top
Properties
  NameDescription
Public propertyDeleteToken
Defines the token to look for indicating the log file should be reset.
Top
Methods
  NameDescription
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Remarks
To use the ResettableFileTarget add a section element for nlog to the configSections element of app.config. Then add the Nlog configuration as a nlog element. The deleteToken attribute on the target element defines the token to look for in log messages to trigger resetting the log file. If not specified defaults to ~DELETE~LOG~FILE~.
<configSections>
  <section name = "nlog" type="NLog.Config.ConfigSectionHandler, NLog"/>
</configSections>

<nlog autoReload="true" xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <extensions>
    <add assembly = "WorkspacesSdkCore" />
  </extensions>

  <targets>
    <target name="logfile" xsi:type="ResettableFile" deleteToken="SomeDeleteToken" fileName="${basedir}/workspacessdk.log" layout="${message}" keepFileOpen="true" />
  </targets>

  <rules>
    <logger name = "*" minlevel="Trace" writeTo="logfile"/>
  </rules>
</nlog>
See Also