Coder Social home page Coder Social logo

logging-1's Introduction

Logging

项目层次说明

Overt.Core.Logging v1.0.2

1. 项目目录

|-dllconfigs                                    配置文件保存
|
|-Exless                                        Exceptionless
|-|-ExlessLogger.cs                        	实现ILogger
|-|-ExlessLoggerProvider.cs                     实现ILoggerProvider
|
|-NLog                                    	NLog
|-|-NLogOptions.cs                       	NLog配置注入类
|
|-ServiceCollectionExtensions.cs            	netcore注入

2. 版本及支持

  • Nuget版本:V 1.0.2
  • 框架支持: netcoreapp2.2

3. 项目依赖

  • netcoreapp2.2
NLog.Extensions.Logging 1.2.1
System.Data.SqlClient 4.4.0
    
Exceptionless.AspNetCore 4.3.2012
Microsoft.Extensions.DependencyInjection 2.2.0
Microsoft.Extensions.Logging 2.2.0

使用

1. Nuget包引用

Install-Package Overt.Core.Logging -Version 1.0.2

2. 使用

(1)NLog
  • 添加配置文件 /dllconfigs/Overt.Core.Logging.dll.config
  • 代码中使用
// ConsoleApplication
 var host = new HostBuilder()
     .ConfigureLogging(ConfigureLogging)    //注入日志组件
     .ConfigureServices(ConfigureServices)  //提供通用注入配置
     .Build();
host.Run();



/// <summary>
/// 添加ILoggerProvider
/// </summary>
/// <param name="context"></param>
/// <param name="loggingBuilder"></param>
private static void ConfigureLogging(HostBuilderContext context, ILoggingBuilder loggingBuilder)
{
    loggingBuilder.AddConfiguration(context.Configuration.GetSection("Logging"));
    loggingBuilder.AddNLogLogging();
}

// WebApplication
public void ConfigureServices(IServiceCollection services)
{
    services.AddMvc();
    services.AddNLogLogging();
}

(2)Exceptionless
  • 配置文件中添加Exceptionless节点
"Exceptionless": {
  "ServerUrl": "exless服务地址",
  "ApiKey": "项目apikey"
  "Tags": "自定义标签"
}
  • 代码中使用
// ConsoleApplication
var host = new HostBuilder()
    .Build();
host.Services.AddExlessLogging();
host.Run();



// WebApplication
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
	app.AddExlessLogging();
}

logging-1's People

Contributors

mojinxun avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.