ChainsawTarget Class |
Namespace: NLog.Targets
The ChainsawTarget type exposes the following members.
Name | Description | |
---|---|---|
ChainsawTarget |
Initializes a new instance of the ChainsawTarget class.
| |
ChainsawTarget(String) |
Initializes a new instance of the ChainsawTarget class with a name.
|
Name | Description | |
---|---|---|
Address |
Gets or sets the network address.
(Inherited from NetworkTarget.) | |
AppInfo |
Gets or sets the log4j:event log4japp-xml-element. By default it's the friendly name of the current AppDomain.
(Inherited from NLogViewerTarget.) | |
Compress |
Type of compression for protocol payload. Useful for UDP where datagram max-size is 8192 bytes.
(Inherited from NetworkTarget.) | |
CompressMinBytes |
Skip compression when protocol payload is below limit to reduce overhead in cpu-usage and additional headers
(Inherited from NetworkTarget.) | |
ConnectionCacheSize |
Gets or sets the size of the connection cache (number of connections which are kept alive). Requires KeepConnection = true
(Inherited from NetworkTarget.) | |
Encoding |
Gets or sets the encoding to be used.
(Inherited from NetworkTarget.) | |
FormattedMessage |
Gets or sets the log4j:event message-xml-element. Default: ${message}
(Inherited from NLogViewerTarget.) | |
IncludeCallSite |
Gets or sets a value indicating whether to include call site (class and method name) in the information sent over the network.
(Inherited from NLogViewerTarget.) | |
IncludeEventProperties |
Gets or sets the option to include all properties from the log events
(Inherited from NLogViewerTarget.) | |
IncludeNdc |
Gets or sets whether to include log4j:NDC in output from ScopeContext nested context.
(Inherited from NLogViewerTarget.) | |
IncludeNLogData |
Gets or sets a value indicating whether to include NLog-specific extensions to log4j schema.
(Inherited from NLogViewerTarget.) | |
IncludeScopeNested |
Gets or sets whether to include log4j:NDC in output from ScopeContext nested context.
(Inherited from NLogViewerTarget.) | |
IncludeScopeProperties |
Gets or sets whether to include the contents of the ScopeContext properties-dictionary.
(Inherited from NLogViewerTarget.) | |
IncludeSourceInfo |
Gets or sets a value indicating whether to include source info (file name and line number) in the information sent over the network.
(Inherited from NLogViewerTarget.) | |
IsInitialized |
Gets a value indicating whether the target has been initialized.
(Inherited from Target.) | |
KeepAliveTimeSeconds |
The number of seconds a connection will remain idle before the first keep-alive probe is sent
(Inherited from NetworkTarget.) | |
KeepConnection |
Gets or sets a value indicating whether to keep connection open whenever possible.
(Inherited from NetworkTarget.) | |
Layout |
Gets or sets the instance of Log4JXmlEventLayout that is used to format log messages.
(Inherited from NLogViewerTarget.) | |
LineEnding |
Gets or sets the end of line value if a newline is appended at the end of log message NewLine.
(Inherited from NetworkTarget.) | |
LoggerName |
Gets or sets the log4j:event logger-xml-attribute. Default: ${logger}
(Inherited from NLogViewerTarget.) | |
LoggingConfiguration |
Gets the logging configuration this target is part of.
(Inherited from Target.) | |
MaxConnections |
Gets or sets the maximum simultaneous connections. Requires KeepConnection = false
(Inherited from NetworkTarget.) | |
MaxMessageSize |
Gets or sets the maximum message size in bytes. On limit breach then OnOverflow action is activated.
(Inherited from NetworkTarget.) | |
MaxQueueSize |
Gets or sets the maximum queue size for a single connection. Requires KeepConnection = true
(Inherited from NetworkTarget.) | |
Name |
Gets or sets the name of the target.
(Inherited from Target.) | |
NdcItemSeparator |
Gets or sets the stack separator for log4j:NDC in output from ScopeContext nested context.
(Inherited from NLogViewerTarget.) | |
NewLine |
Gets or sets a value indicating whether to append newline at the end of log message.
(Inherited from NetworkTarget.) | |
OnConnectionOverflow |
Gets or sets the action that should be taken, when more connections than MaxConnections.
(Inherited from NetworkTarget.) | |
OnOverflow |
Gets or sets the action that should be taken if the message is larger than MaxMessageSize (Inherited from NetworkTarget.) | |
OnQueueOverflow |
Gets or sets the action that should be taken, when more pending messages than MaxQueueSize.
(Inherited from NetworkTarget.) | |
Parameters |
Gets the collection of parameters. Each parameter contains a mapping
between NLog layout and a named parameter.
(Inherited from NLogViewerTarget.) | |
Renderer |
Gets the layout renderer which produces Log4j-compatible XML events.
(Inherited from NLogViewerTarget.) | |
ScopeNestedSeparator |
Gets or sets the separator for ScopeContext operation-states-stack.
(Inherited from NLogViewerTarget.) | |
SendTimeoutSeconds |
The number of seconds a TCP socket send-operation will block before timeout error. Default wait forever when network cable unplugged and tcp-buffer becomes full.
(Inherited from NetworkTarget.) | |
SslProtocols |
Gets or sets the SSL/TLS protocols. Default no SSL/TLS is used. Currently only implemented for TCP.
(Inherited from NetworkTarget.) | |
SyncRoot |
Gets the object which can be used to synchronize asynchronous operations that must rely on the .
(Inherited from Target.) |
Name | Description | |
---|---|---|
CloseTarget |
Closes the target to release any initialized resources
(Inherited from NetworkTarget.) | |
Dispose |
Closes the target.
(Inherited from Target.) | |
Dispose(Boolean) |
Releases unmanaged and - optionally - managed resources.
(Inherited from Target.) | |
Flush |
Flush any pending log messages (in case of asynchronous targets).
(Inherited from Target.) | |
FlushAsync |
Flush any pending log messages asynchronously (in case of asynchronous targets).
(Inherited from NetworkTarget.) | |
GetBytesToWrite |
Gets the bytes to be written.
(Inherited from NetworkTarget.) | |
InitializeTarget |
Initializes the target before writing starts
(Inherited from Target.) | |
PrecalculateVolatileLayouts |
Calls the Precalculate(LogEventInfo) on each volatile layout
used by this target.
This method won't prerender if all layouts in this target are thread-agnostic.
(Inherited from Target.) | |
RenderLogEvent(Layout, LogEventInfo) |
Renders the logevent into a string-result using the provided layout
(Inherited from Target.) | |
RenderLogEventT(LayoutT, LogEventInfo, T) |
Renders the logevent into a result-value by using the provided layout
(Inherited from Target.) | |
ResolveServiceT |
Resolve from DI ServiceRepository (Inherited from Target.) | |
ToString | Returns a string that represents the current object. (Inherited from Target.) | |
Write(AsyncLogEventInfo) |
Sends the
rendered logging event over the network optionally concatenating it with a newline character.
(Inherited from NetworkTarget.) | |
Write(IListAsyncLogEventInfo) |
Writes an array of logging events to the log target. By default it iterates on all
events and passes them to "Write" method. Inheriting classes can use this method to
optimize batch writes.
(Inherited from Target.) | |
Write(LogEventInfo) |
Writes logging event to the target destination
(Inherited from Target.) | |
WriteAsyncLogEvent |
Writes the log to the target.
(Inherited from Target.) | |
WriteAsyncLogEvents(AsyncLogEventInfo) |
Writes the array of log events.
(Inherited from Target.) | |
WriteAsyncLogEvents(IListAsyncLogEventInfo) |
Writes the array of log events.
(Inherited from Target.) | |
WriteAsyncThreadSafe(AsyncLogEventInfo) |
Writes a log event to the log target, in a thread safe manner.
Any override of this method has to provide their own synchronization mechanism.
!WARNING! Custom targets should only override this method if able to provide their
own synchronization mechanism. Layout-objects are not guaranteed to be
thread-safe, so using them without a SyncRoot-object can be dangerous.
(Inherited from Target.) | |
WriteAsyncThreadSafe(IListAsyncLogEventInfo) |
Writes an array of logging events to the log target, in a thread safe manner.
Any override of this method has to provide their own synchronization mechanism.
!WARNING! Custom targets should only override this method if able to provide their
own synchronization mechanism. Layout-objects are not guaranteed to be
thread-safe, so using them without a SyncRoot-object can be dangerous.
(Inherited from Target.) | |
WriteFailedNotInitialized |
LogEvent is written to target, but target failed to successfully initialize
(Inherited from Target.) |
Name | Description | |
---|---|---|
LogEventDropped |
Occurs when LogEvent has been dropped.
(Inherited from NetworkTarget.) |
To set up the target in the configuration file, use the following syntax:
1<?xml version="1.0" ?> 2<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" 3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 4 <targets> 5 <target name="viewer" xsi:type="Chainsaw" address="udp://localhost:4000" /> 6 </targets> 7 8 <rules> 9 <logger name="*" minlevel="Debug" writeTo="viewer" /> 10 </rules> 11</nlog>
To set up the log target programmatically use code like this:
1using NLog; 2using NLog.Targets; 3 4class Example 5{ 6 static void Main(string[] args) 7 { 8 ChainsawTarget target = new ChainsawTarget(); 9 target.Address = "udp://localhost:4000"; 10 11 NLog.Config.SimpleConfigurator.ConfigureForTargetLogging(target, LogLevel.Debug); 12 13 Logger logger = LogManager.GetLogger("Example"); 14 logger.Trace("log message 1"); 15 logger.Debug("log message 2"); 16 logger.Info("log message 3"); 17 logger.Warn("log message 4"); 18 logger.Error("log message 5"); 19 logger.Fatal("log message 6"); 20 } 21}