Using log4net on my project within a self-hosted WCF application Z

Source: Internet
Author: User

  1. ADD reference to Log4net.dll to our console Service host project (we application entry point)
  2. Add the following line to the above project's AssemblyInfo.cs file (allows a custom log4net config file to be specified, W Hich log4net'll "watch" for updates. Quick, but maybe a bit dirty.)

    [assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", Watch = true)]

  3. LOG 4 net Config
    [Assembly:log4net. Config.xmlconfigurator (Watch=true)]
  4. ADD log4net.config file to console project and copy it to the output directory (file properties: "Copy to output directory ")

  5. ADD Log4net.dll reference to all projects where you require logging
  6. Declare the logger as private static member of the classes where you need logging:


     log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

  7. Log where required:
  8. Logger.Info("Starting console service host");

Using log4net on my project within a self-hosted WCF application Z

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.