Logging in .NET
The .NET API produces logging information. The logging facility uses NLog.
NLog is included in the .NET client assembly. For more information about logging with NLog, see https://github.com/NLog/NLog/wiki/.
Logging basics
The NLog Logger class acts as the source of the log messages. In general, use one logger per class and pass in the name of the class as the logger name.
To log a message at a certain level use the write methods provided by the Logger class.
- Fatal
- Error
- Warn
- Info
- Debug
- Trace
Configuring the log output
You must configure NLog to output the log messages produced by your application to a target or targets. NLog provides a large number of targets for your output, including File and Console. NLog also enables you to create your own targets.
In addition to specifying targets for the log output, use NLog configuration to define rules that specify to which target log messages with particular levels or logger names are directed.
- Using a configuration file, NLog.config, that is located in the
same directory as your client application.
For more information, see https://github.com/NLog/NLog/wiki/Configuration-file.
- Using the Configuration API to configure NLog in your application code.
For more information, see https://github.com/NLog/NLog/wiki/Configuration-API.