Using log logs in ASP. NET Core 1.0

Source: Internet
Author: User

Https://github.com/aspnet/Logging
Https://docs.asp.net/en/latest/fundamentals/logging.html

ASP. NET Core 1.0 provides a built-in log module, but you can also use your favorite log framework.

Providers

Community Projects adapt Microsoft.Extensions.Logging for use with different back-ends.

    • Serilog-provider for the Serilog library
    • Elmah.io-provider for the Elmah.io service
    • Loggr-provider for the LOGGR service
    • Nlog-provider for the NLog library
 PublicStartup (iapplicationenvironment appenv) {Iconfigurationbuilder builder=NewConfigurationbuilder (). Setbasepath (Appenv.applicationbasepath). Addjsonfile ("Config.json",false); Configuration=Builder.            Build (); varLogFilePath = Path.Combine (Appenv.applicationbasepath,"Logs/log.txt"); Log.logger=Newloggerconfiguration (). Minimumlevel.debug (). Writeto.textwriter (NewStreamWriter (NewFileStream (LogFilePath, FileMode.OpenOrCreate))) .            Createlogger (); }         PublicIConfiguration Configuration {Get;Set; }  Public voidConfigure (Iapplicationbuilder app, Iloggerfactory loggerfactory) {loggerfactory. Addserilog ().            Addconsole (); App.            Usedeveloperexceptionpage (); App.                        Usemvcwithdefaultroute (); App.                        Usestaticfiles (); App.        Useruntimeinfopage (); }         Public voidconfigureservices (iservicecollection services) {services.        Addmvc (); }    }

Configure the other provider
Https://github.com/serilog/serilog/wiki/Provided-Sinks

. NET Cross-platform tour: Write an ASP. Log to a file on Linux
Http://www.cnblogs.com/cmt/p/4985777.html

Using log logs in ASP. NET Core 1.0

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.