Author: Jaros aw Kowalski <jaak@jkowalski.net>
Translation: crazycoder (Thank you !!)
Original article: http://www.nlog-project.org/visualstudio.html
For more Chinese nlog documents, see nlog document series.
.
Nlog fully supports integration with Visual Studio 2005 (including express edition that supports Visual C # and Visual Basic. net ). It can also be integrated with Visual Studio. NET 2002 and 2003, but some features are unavailable. The following describes the integration features:
- Intelligent Code awareness-intelliisense (TM)
- Integration to add reference dialog box-integration with Add/reference Dialog
- Configuration template-new item templates
- Code snippet-code snippets
Code intelligent awareness-Intelliisense (TM)
Nlog supports code intelligent sensing when editing xml configuration files, regardless of APP. config or independent configuration files. You only need to add the declaration of the two namespaces to the <nlog/> label:
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<!-- configuration goes here -->
</nlog>
Next, modify <target type = "typename"/> to <target xsi: TYPE = "typename"/>. Now Visual Studio can provide smart sensing and inspection functions for your configuration files. Here is a Demo Video (Be careful! This is a 22 MB flash ).
SetNlogTo add reference dialog box
The nlog installer registers the nlog dynamic link library information to the relevant registry project of Visual Studio, in this way, several dynamic link libraries of nlog can be found in the Add reference dialog box of Visual Studio. All versions of Visual Studio can use this function.
Configuration Template
Nlog has three built-in template configuration files. You can add them in the "Add new project" dialog box and quickly apply them to your project. The three templates are:
- A configuration file that defines the target of a file (most commonly used)
- Defines a configuration file for the console target
- An empty configuration file
Note: Make sure to set the "Copy to output directory" attribute of the nlog. config file to "copy always ".
The configuration template only supports different versions of Visual Studio 2005.
Code snippet
Nlog will install an "nlogger" code snippet to Visual Studio 2005, which can be used to quickly add a log recorder to the program. The generated code is as follows:
private static Logger logger = LogManager.GetCurrentClassLogger();
Last Updated: 2006-07-10 11:32:55