Recently, Microsoft redesigned the core
architecture of .NET Framework and ASP.NET. The developers can now use .NET
Core as a cross-platform and open source framework. Likewise, they can use
ASP.NET Core to build a variety of cloud-based web applications and mobile
backends within a shorter amount of time. Microsoft further allows .NET Core
developers to work with an array of popular third-party frameworks and
libraries.
The .NET developers have option to use
a number of third-party logging and tracing tools. Each logging tool is
designed with features to record detailed information about the execution of
various .NET applications. The information recorded by these tools help
programmers or testers to perform debugging and testing more efficiently. They
can use the logs to identify the defects in an application, monitoring/auditing
the live software, and debug the application code after deployment.
As a widely used .NET logging library,
NLog enables developers and testers to generate high quality logs for application
developed with .NET, Silverlight, or Xamarin. It has the capability to process
the diagnostic messages generated by various .NET languages including C# and
VB.NET. The logging platform further augments each diagnostic message with
contextual information like data and time, environment, severity, process and
thread. Also, NLog further allows users to display, store, and pass the log
messages to multiple destinations and by targeting over 30 targets.
Understanding
Important Features of NLog
Simple Configuration
The users can download and install NLog
in a number of ways. A user has option to download the source code of the .NET
logging library as a zip file from Github or avail NLog as binary packages from
Nuget. He can further configure NLog in two distinct ways. Based on his
preference, a user can configure the .NET logging library either through a
single XML file or programmatically. Also, he can make changes to the
configuration without restarting the applications frequently.
Templatable Log Messages
NLog further enables developers and
testers to enhance the quality of log messages by converting them into
templates. The users can easily template the log messages by using a variety of
layout renderers. Each layout renderer is designed as a template macro used in
Layouts. As an attribute of targets, the layouts determine the format in which
the library will log the information. NLog further allows developers to create
custom layout renderers according to their specific needs.
Generate Detailed Logs
The developers can use NLog to add
sophisticated tracing code to .NET applications. In addition to processing the
diagnostic message generated by various .NET languages, NLog further augments
each message with contextual information, and indicates its severity by linking
it to a log level. NLog makes the logs elaborate and comprehensive by
augmenting contextual information like current data and time, stack
trace/information, values of environmental variables, exceptions, machine,
process and thread names. Also, it indicates the severity of the log by
associating with any of the six levels – trace, debug, info, warn, error and
fatal.
Over 30 Targets
NLog supports over thirty targets for a
single message. Each developer has option to decide the way the diagnostic
messages from their source to the targets simply by defining rules. For
instance, a programmer can write rules to display, store and pass the log
messages to varying targets including files, database, console, email message,
and event logs. He has option to store the logs in a database, write the logs
to multiple files, write the event logs to remote or local logs, or format the
logs with a command-line console. Likewise, he can trigger an email each time
an application error occurs. The ASP.NET
developers even have
option to get the log messages written through a built-in trace provided by the
web framework.
Option to Customize and Extend
In addition to adding contextual information
to each log and target multiple destinations, the users also have option to
write custom targets and use custom values. The developers can further create
and registered the custom tags without putting extra time and effort. But they
can write custom logs to get log messages written on non-standard targets and
work with new protocols currently not supported by NLog. Also, they can take
advantage of a special kind of targets called wrappers. Unlike targets,
wrappers lack the capability to perform logging. But the developers can use
wrappers to emulate and modify behaviour of other loggers. They also have
option to use a variety of wrappers according to their specific requirements.
However, NLog is yet to support .NET
Core. The upcoming version 4.4 of the .NET logging platform will support .NET
Core and its new features. At present, NLog supports versions 3.5, 4, 4.5, and
4.6 of .NET Framework; versions 4 and 5 of Silverlight; Windows Phone 8; and
Xamarin iOS and Xamarin Android. Hence, the developers can use NLog to debug
and test a variety of applications more efficiently.
No comments:
Post a Comment