C # Create Windows service +log4net logs

Source: Internet
Author: User
Tags log4net

C # Create a Windows service

    1. Ctrl+shift+n new project, creating a Windows service
    2. Open the Toolbox---right----the Select item---Find the Timer control, watch it, the timer control is system.timer. Not System.Windows.Form. Then Add.
    3. Double-click the Timer control ... Write event ...
    4. Add Log4net Reference Log4Net.dll
    5. Add "Application configuration File", App. config, configure the file
    6. Configure the following files to add log4net

[Assembly:log4net. Config.xmlconfigurator ()]

7.

Log4net. ILog log = log4net. Logmanager.getlogger ("Winverifyserver");

String runTime = new Appsettingsreader (). GetValue ("RunTime", typeof (String)) as String;

    1. In the Server.cs design interface, right-click--"Add Installer"
    2. Select the first control, click F4, switch to the property view on the right, change the account property in the Properties view to LocalService (Local service)

    1. Select the second control above, click F4, and switch to the property view on the right. Change servicename for your own favorite service name, remember not to conflict with the system Oh ~, Pro! StartType default to Manual, you can change to automatic

(Automatic) or disabled (Disabled)

    1. Compile the project, and then win+r enter cmd into the command window. To find InstallUtil.exe in the directory corresponding to the. NET version, my project uses. NET 2.0, so the path is C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727

11. Final Result:

C # Create Windows service +log4net logs

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.