Nlog article series-integration with Visual Studio

Source: Internet
Author: User
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:

  1. Intelligent Code awareness-intelliisense (TM)
  2. Integration to add reference dialog box-integration with Add/reference Dialog
  3. Configuration template-new item templates
  4. 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.