Skip to content

Commit a599c86

Browse files
committed
fix: 修复Exceptionless 4.6.2 版本写日志的问题
1 parent 7e02d71 commit a599c86

File tree

11 files changed

+66
-59
lines changed

11 files changed

+66
-59
lines changed

framework/src/Bing.Logs.Exceptionless/Bing/Logs/Exceptionless/ExceptionlessProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace Bing.Logs.Exceptionless
1212
/// <summary>
1313
/// Exceptionless日志提供程序
1414
/// </summary>
15-
public class ExceptionlessProvider : ILogProvider
15+
internal class ExceptionlessProvider : ILogProvider
1616
{
1717
#region 属性
1818

framework/src/Bing.Logs.Exceptionless/Bing/Logs/Exceptionless/Extensions.Service.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public static void AddExceptionless(this IServiceCollection services,
2828
services.TryAddScoped<ILog, Log>();
2929

3030
configAction?.Invoke(ExceptionlessClient.Default.Configuration);
31+
ExceptionlessClient.Default.Startup();
3132
}
3233

3334
/// <summary>

modules/admin/src/Bing.Admin.FreeSQL/Modules/LogModule.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ public class LogModule : AspNetCoreBingModule
3131
/// <param name="services">服务集合</param>
3232
public override IServiceCollection AddServices(IServiceCollection services)
3333
{
34-
services.AddNLog();
35-
//services.AddExceptionless(o =>
36-
//{
37-
// o.ApiKey = "FKLLqe2hMowxb1udH8w76DaGjUxFw04BZv3P0AOO";
38-
// o.ServerUrl = "http://106.12.130.45:50000";
39-
//});
34+
//services.AddNLog();
35+
services.AddExceptionless(x =>
36+
{
37+
x.ServerUrl = "http://10.186.135.27:5100";
38+
x.ApiKey = "yIgaHwtLwbN9VoUCP0UYpSPVzwpmeNSdVSfVIVta";
39+
});
4040
return services;
4141
}
4242
}

samples/Bing.Samples.Hangfire/Bing.Samples.Hangfire.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
<Project Sdk="Microsoft.NET.Sdk.Web">
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
44
<TargetFramework>netcoreapp3.1</TargetFramework>
55
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
66
</PropertyGroup>
77

88
<ItemGroup>
9+
<PackageReference Include="AspectCore.Extensions.Hosting" Version="2.2.0" />
910
<PackageReference Include="Hangfire.AspNetCore" Version="1.7.16" />
1011
<PackageReference Include="Hangfire.MemoryStorage" Version="1.7.0" />
1112
</ItemGroup>
1213

1314
<ItemGroup>
1415
<ProjectReference Include="..\..\framework\src\Bing.AspNetCore\Bing.AspNetCore.csproj" />
16+
<ProjectReference Include="..\..\framework\src\Bing.Logs.Exceptionless\Bing.Logs.Exceptionless.csproj" />
1517
<ProjectReference Include="..\..\framework\src\Bing.Logs.NLog\Bing.Logs.NLog.csproj" />
1618
</ItemGroup>
1719

samples/Bing.Samples.Hangfire/Jobs/DebugLogJob.cs

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
using Bing.DependencyInjection;
55
using Bing.Logs;
66
using Bing.Logs.Abstractions;
7+
using Exceptionless;
78
using Microsoft.Extensions.Logging;
9+
using el = global::Exceptionless;
10+
using LogLevel = Exceptionless.Logging.LogLevel;
811

912
namespace Bing.Samples.Hangfire.Jobs
1013
{
@@ -42,32 +45,37 @@ public void WriteLog()
4245
Debug.WriteLine("-------------------------------------------------------------------------------------------------------------------------------------------");
4346
Debug.WriteLine($"1、【{DateTime.Now:yyyy-MM-dd HH:mm:ss.sss}{nameof(WriteLog)} | 写入日志");
4447
var log = GetLog();
45-
log.Class(GetType().FullName)
46-
.Caption("DebugLogJob")
47-
.Content($"2、【{DateTime.Now:yyyy-MM-dd HH:mm:ss.sss}{nameof(WriteLog)} | 写入日志")
48-
.Trace();
48+
//log.Class(GetType().FullName)
49+
// .Caption("DebugLogJob")
50+
// .Content($"2、【{DateTime.Now:yyyy-MM-dd HH:mm:ss.sss}】 {nameof(WriteLog)} | 写入日志")
51+
// .Debug();
52+
log.Info($"隔壁老王的信息【{DateTime.Now:yyyy-MM-dd HH:mm:ss.sss}】 ");
53+
el.ExceptionlessClient.Default
54+
.CreateLog($"隔壁老王的信息-Source【{DateTime.Now:yyyy-MM-dd HH:mm:ss.sss}】 ", LogLevel.Info).Submit();
55+
el.ExceptionlessClient.Default
56+
.CreateLog($"隔壁老王的信息-Source-NotLevel【{DateTime.Now:yyyy-MM-dd HH:mm:ss.sss}】 ").Submit();
4957

50-
Logger.Class(GetType().FullName)
51-
.Caption("DebugLogJob")
52-
.Content($"3-1、【{DateTime.Now:yyyy-MM-dd HH:mm:ss.sss}{nameof(WriteLog)} | 写入日志")
53-
.Trace();
54-
Logger.Class(GetType().FullName)
55-
.Caption("DebugLogJob")
56-
.Content($"3-2、【{DateTime.Now:yyyy-MM-dd HH:mm:ss.sss}{nameof(WriteLog)} | 写入日志")
57-
.Trace();
58-
Logger.Class(GetType().FullName)
59-
.Caption("DebugLogJob")
60-
.Content($"3-3、【{DateTime.Now:yyyy-MM-dd HH:mm:ss.sss}{nameof(WriteLog)} | 写入日志")
61-
.Trace();
62-
Logger.Class(GetType().FullName)
63-
.Caption("DebugLogJob")
64-
.Content($"3-4、【{DateTime.Now:yyyy-MM-dd HH:mm:ss.sss}{nameof(WriteLog)} | 写入日志")
65-
.Trace();
58+
//Logger.Class(GetType().FullName)
59+
// .Caption("DebugLogJob")
60+
// .Content($"3-1、【{DateTime.Now:yyyy-MM-dd HH:mm:ss.sss}】 {nameof(WriteLog)} | 写入日志")
61+
// .Debug();
62+
//Logger.Class(GetType().FullName)
63+
// .Caption("DebugLogJob")
64+
// .Content($"3-2、【{DateTime.Now:yyyy-MM-dd HH:mm:ss.sss}】 {nameof(WriteLog)} | 写入日志")
65+
// .Trace();
66+
//Logger.Class(GetType().FullName)
67+
// .Caption("DebugLogJob")
68+
// .Content($"3-3、【{DateTime.Now:yyyy-MM-dd HH:mm:ss.sss}】 {nameof(WriteLog)} | 写入日志")
69+
// .Trace();
70+
//Logger.Class(GetType().FullName)
71+
// .Caption("DebugLogJob")
72+
// .Content($"3-4、【{DateTime.Now:yyyy-MM-dd HH:mm:ss.sss}】 {nameof(WriteLog)} | 写入日志")
73+
// .Trace();
6674

67-
SysLogger.LogInformation($"4-1、【系统日志】【{DateTime.Now:yyyy-MM-dd HH:mm:ss.sss}{nameof(WriteLog)} | 写入日志");
68-
SysLogger.LogInformation($"4-2、【系统日志】【{DateTime.Now:yyyy-MM-dd HH:mm:ss.sss}{nameof(WriteLog)} | 写入日志");
69-
SysLogger.LogInformation($"4-3、【系统日志】【{DateTime.Now:yyyy-MM-dd HH:mm:ss.sss}{nameof(WriteLog)} | 写入日志");
70-
SysLogger.LogInformation($"4-4、【系统日志】【{DateTime.Now:yyyy-MM-dd HH:mm:ss.sss}{nameof(WriteLog)} | 写入日志");
75+
//SysLogger.LogInformation($"4-1、【系统日志】【{DateTime.Now:yyyy-MM-dd HH:mm:ss.sss}】 {nameof(WriteLog)} | 写入日志");
76+
//SysLogger.LogInformation($"4-2、【系统日志】【{DateTime.Now:yyyy-MM-dd HH:mm:ss.sss}】 {nameof(WriteLog)} | 写入日志");
77+
//SysLogger.LogInformation($"4-3、【系统日志】【{DateTime.Now:yyyy-MM-dd HH:mm:ss.sss}】 {nameof(WriteLog)} | 写入日志");
78+
//SysLogger.LogInformation($"4-4、【系统日志】【{DateTime.Now:yyyy-MM-dd HH:mm:ss.sss}】 {nameof(WriteLog)} | 写入日志");
7179
}
7280

7381
private ILog GetLog()

samples/Bing.Samples.Hangfire/Modules/HangfireModule.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public override void UseModule(IApplicationBuilder app)
5050
GlobalConfiguration.Configuration.UseActivator(new HangfireDIActivator(app.ApplicationServices));
5151
app.UseHangfireDashboard();
5252
app.UseHangfireServer();
53-
RecurringJob.AddOrUpdate<IDebugLogJob>(x => x.WriteLog(), "0/5 * * * * ? ", TimeZoneInfo.Local);
53+
RecurringJob.AddOrUpdate<IDebugLogJob>(x => x.WriteLog(), "0/5 5 * * * ? ", TimeZoneInfo.Local);
5454
}
5555
}
5656

samples/Bing.Samples.Hangfire/Modules/LogModule.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.ComponentModel;
22
using Bing.AspNetCore;
33
using Bing.Core.Modularity;
4+
using Bing.Logs.Exceptionless;
45
using Bing.Logs.NLog;
56
using Microsoft.Extensions.DependencyInjection;
67

@@ -30,7 +31,12 @@ public class LogModule : AspNetCoreBingModule
3031
/// <param name="services">服务集合</param>
3132
public override IServiceCollection AddServices(IServiceCollection services)
3233
{
33-
services.AddNLog();
34+
//services.AddNLog();
35+
services.AddExceptionless(x =>
36+
{
37+
x.ServerUrl = "http://10.186.135.27:5100";
38+
x.ApiKey = "yIgaHwtLwbN9VoUCP0UYpSPVzwpmeNSdVSfVIVta";
39+
});
3440
return services;
3541
}
3642
}
Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.IO;
4-
using System.Linq;
5-
using System.Threading.Tasks;
6-
using Microsoft.AspNetCore;
7-
using Microsoft.AspNetCore.Hosting;
8-
using Microsoft.Extensions.Configuration;
9-
using Microsoft.Extensions.Logging;
1+
using Microsoft.AspNetCore.Hosting;
2+
using Microsoft.Extensions.Hosting;
3+
using AspectCore.Extensions.Hosting;
104

115
namespace Bing.Samples.Hangfire
126
{
@@ -17,8 +11,10 @@ public static void Main(string[] args)
1711
CreateWebHostBuilder(args).Build().Run();
1812
}
1913

20-
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
21-
WebHost.CreateDefaultBuilder(args)
22-
.UseStartup<Startup>();
14+
public static IHostBuilder CreateWebHostBuilder(string[] args) =>
15+
Host.CreateDefaultBuilder(args).UseServiceContext().ConfigureWebHostDefaults(webBuilder =>
16+
{
17+
webBuilder.UseStartup<Startup>();
18+
});
2319
}
2420
}

samples/Bing.Samples.Hangfire/Startup.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using System;
2-
using AspectCore.Extensions.DependencyInjection;
3-
using Bing.Samples.Hangfire.Modules;
1+
using Bing.Samples.Hangfire.Modules;
42
using Microsoft.AspNetCore.Builder;
53
using Microsoft.AspNetCore.Hosting;
64
using Microsoft.Extensions.Configuration;
@@ -32,21 +30,20 @@ public Startup(IConfiguration configuration)
3230
/// 配置服务
3331
/// </summary>
3432
/// <param name="services">服务集合</param>
35-
public IServiceProvider ConfigureServices(IServiceCollection services)
33+
public void ConfigureServices(IServiceCollection services)
3634
{
3735
services.AddBing()
3836
.AddModule<AppModule>()
3937
.AddModule<LogModule>()
4038
.AddModule<HangfireModule>();
41-
return services.BuildServiceContextProvider();
4239
}
4340

4441
/// <summary>
4542
/// 配置请求管道
4643
/// </summary>
4744
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
4845
{
49-
loggerFactory.AddSysLogProvider();
46+
//loggerFactory.AddSysLogProvider();
5047
app.UseBing();
5148
}
5249
}
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
{
22
"Logging": {
33
"LogLevel": {
4-
"Default": "Debug",
5-
"System": "Information",
6-
"Microsoft": "Information"
4+
"Default": "Debug"
75
}
86
}
97
}

0 commit comments

Comments
 (0)