提交.Net6版本
This commit is contained in:
65
Yi.Framework.Net6/Yi.Framework.OcelotGateway/Log4net.config
Normal file
65
Yi.Framework.Net6/Yi.Framework.OcelotGateway/Log4net.config
Normal file
@@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<log4net>
|
||||
<!-- 将日志以回滚文件的形式写到文件中 -->
|
||||
<!-- 按日期切分日志文件,并将日期作为日志文件的名字 -->
|
||||
<!--Error-->
|
||||
<appender name="ErrorLog" type="log4net.Appender.RollingFileAppender">
|
||||
<!--不加utf-8编码格式,中文字符将显示成乱码-->
|
||||
<param name="Encoding" value="utf-8" />
|
||||
<file value="log/"/>
|
||||
<appendToFile value="true" />
|
||||
<rollingStyle value="Date" />
|
||||
<!--日期的格式,每天换一个文件记录,如不设置则永远只记录一天的日志,需设置-->
|
||||
<datePattern value=""GlobalExceptionLogs_"yyyyMMdd".log"" />
|
||||
<!--日志文件名是否为静态-->
|
||||
<StaticLogFileName value="false"/>
|
||||
<!--多线程时采用最小锁定-->
|
||||
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
|
||||
<!--布局(向用户显示最后经过格式化的输出信息)-->
|
||||
<layout type="log4net.Layout.PatternLayout">
|
||||
<conversionPattern value="%date| %-5level %newline%message%newline--------------------------------%newline" />
|
||||
</layout>
|
||||
<filter type="log4net.Filter.LevelRangeFilter">
|
||||
<levelMin value="ERROR" />
|
||||
<levelMax value="FATAL" />
|
||||
</filter>
|
||||
</appender>
|
||||
<!--Error-->
|
||||
|
||||
|
||||
|
||||
<!--Info-->
|
||||
<appender name="InfoLog" type="log4net.Appender.RollingFileAppender">
|
||||
<!--不加utf-8编码格式,中文字符将显示成乱码-->
|
||||
<param name="Encoding" value="utf-8" />
|
||||
<!--定义文件存放位置-->
|
||||
<file value="log/"/>
|
||||
<appendToFile value="true" />
|
||||
<rollingStyle value="Date" />
|
||||
<!--日志文件名是否为静态-->
|
||||
<StaticLogFileName value="false"/>
|
||||
<!--日期的格式,每天换一个文件记录,如不设置则永远只记录一天的日志,需设置-->
|
||||
<datePattern value=""GlobalInfoLogs_"yyyyMMdd".log"" />
|
||||
<!--多线程时采用最小锁定-->
|
||||
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
|
||||
<!--布局(向用户显示最后经过格式化的输出信息)-->
|
||||
<layout type="log4net.Layout.PatternLayout">
|
||||
<conversionPattern value="%date| %-5level%c %newline%message%newline--------------------------------%newline" />
|
||||
</layout>
|
||||
<filter type="log4net.Filter.LevelRangeFilter">
|
||||
<levelMin value="DEBUG" />
|
||||
<levelMax value="WARN" />
|
||||
</filter>
|
||||
</appender>
|
||||
<!--Info-->
|
||||
|
||||
<root>
|
||||
<!-- 控制级别,由低到高:ALL|DEBUG|INFO|WARN|ERROR|FATAL|OFF -->
|
||||
<!-- 比如定义级别为INFO,则INFO级别向下的级别,比如DEBUG日志将不会被记录 -->
|
||||
<!-- 如果没有定义LEVEL的值,则缺省为DEBUG -->
|
||||
<level value="ALL" />
|
||||
<!-- 按日期切分日志文件,并将日期作为日志文件的名字 -->
|
||||
<appender-ref ref="ErrorLog" />
|
||||
<appender-ref ref="InfoLog" />
|
||||
</root>
|
||||
</log4net>
|
||||
42
Yi.Framework.Net6/Yi.Framework.OcelotGateway/Program.cs
Normal file
42
Yi.Framework.Net6/Yi.Framework.OcelotGateway/Program.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.OcelotGateway
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
CreateHostBuilder(args).Build().Run();
|
||||
}
|
||||
|
||||
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||
Host.CreateDefaultBuilder(args)
|
||||
.ConfigureAppConfiguration((hostBuilderContext, configurationBuilder) =>
|
||||
{
|
||||
configurationBuilder.AddCommandLine(args);
|
||||
configurationBuilder.AddJsonFile("appsettings.json", optional: true, reloadOnChange: false);
|
||||
configurationBuilder.AddJsonFile("configuration.json", optional: false, reloadOnChange: true);
|
||||
#region
|
||||
//Apollo<6C><6F><EFBFBD><EFBFBD>
|
||||
#endregion
|
||||
//configurationBuilder.AddApolloService("Yi");
|
||||
})
|
||||
.ConfigureLogging(loggingBuilder =>
|
||||
{
|
||||
loggingBuilder.AddFilter("System", Microsoft.Extensions.Logging.LogLevel.Warning);
|
||||
loggingBuilder.AddFilter("Microsoft", Microsoft.Extensions.Logging.LogLevel.Warning);
|
||||
loggingBuilder.AddLog4Net();
|
||||
})
|
||||
.ConfigureWebHostDefaults(webBuilder =>
|
||||
{
|
||||
webBuilder.UseStartup<Startup>().UseUrls("http://*:7200");
|
||||
});
|
||||
}
|
||||
}
|
||||
80
Yi.Framework.Net6/Yi.Framework.OcelotGateway/Startup.cs
Normal file
80
Yi.Framework.Net6/Yi.Framework.OcelotGateway/Startup.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.HttpsPolicy;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Ocelot.DependencyInjection;
|
||||
using Ocelot.Middleware;
|
||||
using Ocelot.Provider.Consul;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Ocelot.Cache.CacheManager;
|
||||
using Yi.Framework.WebCore.MiddlewareExtend;
|
||||
using Ocelot.Provider.Polly;
|
||||
|
||||
namespace Yi.Framework.OcelotGateway
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
public Startup(IConfiguration configuration)
|
||||
{
|
||||
Configuration = configuration;
|
||||
}
|
||||
|
||||
public IConfiguration Configuration { get; }
|
||||
|
||||
// This method gets called by the runtime. Use this method to add services to the container.
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
|
||||
services.AddControllers();
|
||||
#region
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#endregion
|
||||
services.AddCorsService();
|
||||
|
||||
#region
|
||||
//<2F><><EFBFBD>ط<EFBFBD><D8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#endregion
|
||||
services.AddOcelot().AddConsul().AddCacheManager(x =>{x.WithDictionaryHandle();}).AddPolly();
|
||||
|
||||
#region
|
||||
//Swagger<65><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#endregion
|
||||
services.AddSwaggerService<Program>("Yi.Framework.OcelotGateway");
|
||||
#region
|
||||
//Jwt<77><74>Ȩ<EFBFBD><C8A8><EFBFBD><EFBFBD>
|
||||
#endregion
|
||||
services.AddJwtService();
|
||||
}
|
||||
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
//if (env.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
#region
|
||||
//Swagger<65><72><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>
|
||||
#endregion
|
||||
app.UseSwaggerService(new SwaggerModel("api/api/swagger/v1/swagger.json","API<50><49><EFBFBD><EFBFBD>"), new SwaggerModel("api/item/swagger/v1/swagger.json", "<22><>̬ҳ<CCAC><D2B3><EFBFBD><EFBFBD>"));
|
||||
}
|
||||
#region
|
||||
//<2F><><EFBFBD>ط<EFBFBD><D8B7><EFBFBD>ע<EFBFBD><D7A2>
|
||||
#endregion
|
||||
app.UseOcelot();
|
||||
|
||||
#region
|
||||
//<2F><>Ȩע<C8A8><D7A2>
|
||||
#endregion
|
||||
app.UseAuthentication();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0"?>
|
||||
<doc>
|
||||
<assembly>
|
||||
<name>Yi.Framework.OcelotGateway</name>
|
||||
</assembly>
|
||||
<members>
|
||||
</members>
|
||||
</doc>
|
||||
@@ -0,0 +1,23 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<DocumentationFile>D:\CC.Yi\CC.Yi\Yi.Framework\Yi.Framework.OcelotGateway\SwaggerDoc.xml</DocumentationFile>
|
||||
<NoWarn>1701;1702;CS1591</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Ocelot" Version="17.0.1" />
|
||||
<PackageReference Include="Ocelot.Cache.CacheManager" Version="17.0.1" />
|
||||
<PackageReference Include="Ocelot.Provider.Consul" Version="17.0.1" />
|
||||
<PackageReference Include="Ocelot.Provider.Polly" Version="17.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Yi.Framework.WebCore\Yi.Framework.WebCore.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user