Merge branch 'framework' of https://gitee.com/ccnetcore/Yi into framework

This commit is contained in:
橙子
2023-03-05 20:30:53 +08:00
8 changed files with 84 additions and 8 deletions

View File

@@ -1,4 +1,5 @@
using System;
using NLog;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
@@ -22,12 +23,12 @@ namespace Yi.Framework.Core.Module
{
StartBFSNodes(StartType);
var result= RemoveDuplicate(ResultType);
Logger? _logger = LogManager.Setup().LoadConfigurationFromAssemblyResource(typeof(ModuleManager).Assembly).GetCurrentClassLogger();
foreach (var r in result)
{
//添加全局模块程序集
ModuleAssembly.Add(r.Assembly);
Console.WriteLine($"意框架正在加载模块:{r.Name}");
_logger.Info($"意框架正在加载模块:{r.Name}");
}
return result;
}

View File

@@ -12,6 +12,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="NLog.Extensions.Logging" Version="5.2.2" />
<PackageReference Include="SqlSugarCoreNoDrive" Version="5.1.3.50-preview01" />
<PackageReference Include="StartupModules" Version="4.0.0" />
</ItemGroup>

View File

@@ -1,6 +1,8 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
using StartupModules;
using System;
using System.Collections.Generic;
@@ -33,9 +35,6 @@ namespace Yi.Framework.Core
services.AddSingleton(new Appsettings(context.Configuration));
//全盘扫描,自动依赖注入
services.AddAutoIocServer();
}
}
}

View File

@@ -1,12 +1,18 @@
using AspNetCore.Microsoft.AspNetCore.Hosting;
using NLog;
using NLog.Extensions.Logging;
using Yi.Framework.Core.Autofac.Extensions;
using Yi.Framework.Core.Autofac.Modules;
using Yi.Framework.Core.Extensions;
using Yi.Framework.Core.Module;
using Yi.Template.Application;
using Yi.Template.Web;
var builder = WebApplication.CreateBuilder(args);
//配置日志
builder.Services.AddLogging(builder => { builder.ClearProviders().AddNLog("nlog.config").SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace); });
Logger? _logger = LogManager.Setup().LoadConfigurationFromAssemblyResource(typeof(Program).Assembly).GetCurrentClassLogger();
_logger.Info("-----( ¯ □ ¯ )YiFrameowrk框架启动-----");
//设置启动url
builder.WebHost.UseStartUrlsServer(builder.Configuration);

View File

@@ -15,6 +15,12 @@
<ProjectReference Include="..\Yi.Template.Sqlsugar\Yi.Template.Sqlsugar.csproj" />
</ItemGroup>
<ItemGroup>
<Content Update="nlog.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<None Update="key.pem">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>

View File

@@ -1,12 +1,18 @@
using AspNetCore.Microsoft.AspNetCore.Hosting;
using NLog;
using NLog.Extensions.Logging;
using Yi.Framework.Core.Autofac.Extensions;
using Yi.Framework.Core.Autofac.Modules;
using Yi.Framework.Core.Extensions;
using Yi.Framework.Core.Module;
using Yi.Template.Application;
using Yi.Template.Web;
var builder = WebApplication.CreateBuilder(args);
//配置日志
builder.Services.AddLogging(builder => { builder.ClearProviders().AddNLog("nlog.config").SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace); });
Logger? _logger = LogManager.Setup().LoadConfigurationFromAssemblyResource(typeof(Program).Assembly).GetCurrentClassLogger();
_logger.Info("-----( ¯ □ ¯ )YiFrameowrk框架启动-----");
//设置启动url
builder.WebHost.UseStartUrlsServer(builder.Configuration);

View File

@@ -15,6 +15,12 @@
<ProjectReference Include="..\Yi.Template.Sqlsugar\Yi.Template.Sqlsugar.csproj" />
</ItemGroup>
<ItemGroup>
<Content Update="nlog.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<None Update="key.pem">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>

View File

@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
throwExceptions="false"
internalLogLevel="Off">
<variable name="archiveAboveSize" value="10485760"/>
<variable name="maxArchiveFiles" value="50"/>
<variable name="layout" value="${date:format=HH\:mm\:ss.fff}|${level}|${threadId:format=threadId}|${logger}${newline}>>${message} ${exception:format=tostring}"/>
<variable name="logsRootPath" value="${basedir}/logs/${shortdate}" />
<targets>
<target xsi:type="File"
name="AllFile"
fileName="${logsRootPath}/AllFile/log.log"
layout="${layout}${newline}"
archiveAboveSize="${archiveAboveSize}"
maxArchiveFiles="${maxArchiveFiles}" />
<target xsi:type="ColoredConsole"
name="ColoredConsole"
layout="${layout}${newline}">
<highlight-row condition="level == LogLevel.Info" foregroundColor="White" />
<highlight-row condition="level == LogLevel.Debug" foregroundColor="Green" />
<highlight-row condition="level == LogLevel.Warn" foregroundColor="Yellow" />
<highlight-row condition="level == LogLevel.Error" foregroundColor="Red" />
<highlight-row condition="level == LogLevel.Fatal" foregroundColor="Red" backgroundColor="White" />
</target>
<target xsi:type="File" name="OwnFile"
fileName="${logsRootPath}/OwnFile/log.log"
layout="${layout}|Url: ${aspnet-request-url}|Action: ${aspnet-mvc-action}${newline}"
archiveAboveSize="${archiveAboveSize}"
maxArchiveFiles="${maxArchiveFiles}" />
</targets>
<rules>
<logger name="Quartz.*" maxlevel="Warn" final="true" />
<logger name="Grpc.*" maxlevel="Debug" final="true" />
<logger name="Grpc.*" maxlevel="Trace" final="true" />
<logger name="Microsoft.EntityFrameworkCore.*" maxlevel="Warn" final="true" />
<logger name="Microsoft.AspNetCore.*" maxlevel="Warn" final="true" />
<logger name="Microsoft.AspNetCore.SignalR.*" maxlevel="Warn" final="true" />
<logger name="*" minlevel="Trace" maxlevel="Fatal" writeTo="AllFile,ColoredConsole"/>
<logger name="Microsoft.Hosting.Lifetime" minlevel="Info" writeTo="ColoredConsole,OwnFile" final="true" />
<logger name="Microsoft.*" maxlevel="Info" final="true" />
<logger name="*" minlevel="Trace" writeTo="OwnFile" />
</rules>
</nlog>