.. rst-class:: center
Getting Started (Quick Start)
If you are totally new to logging in software, first read :ref:`introtologging`.
If you are new to tag-based logging, read :ref:`intrototaglogging`.
Step 1: Install Using NuGet
NuLog is delivered using NuGet. Look for, and install the NuLog package into any project you wish to use NuLog for. NuLog supports .Net versions 3.5, 4 and 4.5.2 (and on).
You'll want to get your configuration squared away. For more information on configuring NuLog, head over to :ref:`configtemplate`.
Step 2: Get Standard Logger
.. literalinclude:: /../../NuLogSnippets/Docs/GetStandardLogger.cs :lines: 5-13,20-21 :emphasize-lines: 1-2,8-9 :linenos:
Step 3: Log
.. literalinclude:: /../../NuLogSnippets/Docs/GetStandardLogger.cs :lines: 6-11,13-22 :emphasize-lines: 11-13 :linenos:
Log vs. LogNow
NuLog is designed to defer the actual action of dispatching and logging a log event to a queue that is managed by a background process (thread). This allows control to return to the logging method much sooner, instead of having to wait for the log message to be dispatched before returning. When calling
Log on the Logger, the log event is generated by the Logger, then added to a queue for dispatch by a background process. To dispatch a log event for immediate logging, use
It is highly suggested that you use
Log for almost everything, only using
LogNow for log events that are more critically recorded.
The Finalizer on the class that dispatches the log events has been overridden to ensure that no new log events are queued, and any existing log events in the queue are dispatched, before the dispatcher is disposed. This means that there is a higher degree of certainty that queued log events are dispatched before the program exits. The only time queued log events won't be dispatched, is in case of a total crash of the application, or power failure - which would likely cause log event failure, anyways. If the nature of the log event is such that failure cannot be risked, just use
LogNow for the event instead.