Merge branch 'merge/release/2.2-to-master'
This commit is contained in:
commit
3e0ee5a711
|
|
@ -25,6 +25,7 @@
|
||||||
<MicrosoftExtensionsLoggingConfigurationPackageVersion>3.0.0-alpha1-10584</MicrosoftExtensionsLoggingConfigurationPackageVersion>
|
<MicrosoftExtensionsLoggingConfigurationPackageVersion>3.0.0-alpha1-10584</MicrosoftExtensionsLoggingConfigurationPackageVersion>
|
||||||
<MicrosoftExtensionsLoggingConsolePackageVersion>3.0.0-alpha1-10584</MicrosoftExtensionsLoggingConsolePackageVersion>
|
<MicrosoftExtensionsLoggingConsolePackageVersion>3.0.0-alpha1-10584</MicrosoftExtensionsLoggingConsolePackageVersion>
|
||||||
<MicrosoftExtensionsLoggingDebugPackageVersion>3.0.0-alpha1-10584</MicrosoftExtensionsLoggingDebugPackageVersion>
|
<MicrosoftExtensionsLoggingDebugPackageVersion>3.0.0-alpha1-10584</MicrosoftExtensionsLoggingDebugPackageVersion>
|
||||||
|
<MicrosoftExtensionsLoggingEventSourcePackageVersion>3.0.0-alpha1-10584</MicrosoftExtensionsLoggingEventSourcePackageVersion>
|
||||||
<MicrosoftExtensionsLoggingPackageVersion>3.0.0-alpha1-10584</MicrosoftExtensionsLoggingPackageVersion>
|
<MicrosoftExtensionsLoggingPackageVersion>3.0.0-alpha1-10584</MicrosoftExtensionsLoggingPackageVersion>
|
||||||
<MicrosoftNETCoreApp20PackageVersion>2.0.9</MicrosoftNETCoreApp20PackageVersion>
|
<MicrosoftNETCoreApp20PackageVersion>2.0.9</MicrosoftNETCoreApp20PackageVersion>
|
||||||
<MicrosoftNETCoreApp21PackageVersion>2.1.3</MicrosoftNETCoreApp21PackageVersion>
|
<MicrosoftNETCoreApp21PackageVersion>2.1.3</MicrosoftNETCoreApp21PackageVersion>
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="$(MicrosoftExtensionsLoggingConfigurationPackageVersion)" PrivateAssets="None" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="$(MicrosoftExtensionsLoggingConfigurationPackageVersion)" PrivateAssets="None" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="$(MicrosoftExtensionsLoggingConsolePackageVersion)" PrivateAssets="None" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="$(MicrosoftExtensionsLoggingConsolePackageVersion)" PrivateAssets="None" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="$(MicrosoftExtensionsLoggingDebugPackageVersion)" PrivateAssets="None" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="$(MicrosoftExtensionsLoggingDebugPackageVersion)" PrivateAssets="None" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Logging.EventSource" Version="$(MicrosoftExtensionsLoggingEventSourcePackageVersion)" PrivateAssets="None" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -190,6 +190,7 @@ namespace Microsoft.AspNetCore
|
||||||
logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
|
logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
|
||||||
logging.AddConsole();
|
logging.AddConsole();
|
||||||
logging.AddDebug();
|
logging.AddDebug();
|
||||||
|
logging.AddEventSourceLogger();
|
||||||
})
|
})
|
||||||
.ConfigureServices((hostingContext, services) =>
|
.ConfigureServices((hostingContext, services) =>
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,16 @@
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics.Tracing;
|
||||||
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using Microsoft.AspNetCore.HostFiltering;
|
using Microsoft.AspNetCore.HostFiltering;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
|
|
@ -49,6 +54,54 @@ namespace Microsoft.AspNetCore.Tests
|
||||||
Assert.Contains("NewHost", options.AllowedHosts);
|
Assert.Contains("NewHost", options.AllowedHosts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void CreateDefaultBuilder_RegistersEventSourceLogger()
|
||||||
|
{
|
||||||
|
var listener = new TestEventListener();
|
||||||
|
var host = WebHost.CreateDefaultBuilder()
|
||||||
|
.Configure(_ => { })
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
var logger = host.Services.GetRequiredService<ILogger<WebHostTests>>();
|
||||||
|
logger.LogInformation("Request starting");
|
||||||
|
|
||||||
|
var events = listener.EventData.ToArray();
|
||||||
|
Assert.Contains(events, args =>
|
||||||
|
args.EventSource.Name == "Microsoft-Extensions-Logging" &&
|
||||||
|
args.Payload.OfType<string>().Any(p => p.Contains("Request starting")));
|
||||||
|
}
|
||||||
|
|
||||||
|
private class TestEventListener : EventListener
|
||||||
|
{
|
||||||
|
private volatile bool _disposed;
|
||||||
|
|
||||||
|
private ConcurrentQueue<EventWrittenEventArgs> _events = new ConcurrentQueue<EventWrittenEventArgs>();
|
||||||
|
|
||||||
|
public IEnumerable<EventWrittenEventArgs> EventData => _events;
|
||||||
|
|
||||||
|
protected override void OnEventSourceCreated(EventSource eventSource)
|
||||||
|
{
|
||||||
|
if (eventSource.Name == "Microsoft-Extensions-Logging")
|
||||||
|
{
|
||||||
|
EnableEvents(eventSource, EventLevel.Informational);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnEventWritten(EventWrittenEventArgs eventData)
|
||||||
|
{
|
||||||
|
if (!_disposed)
|
||||||
|
{
|
||||||
|
_events.Enqueue(eventData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Dispose()
|
||||||
|
{
|
||||||
|
_disposed = true;
|
||||||
|
base.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class ReloadableMemorySource : IConfigurationSource
|
private class ReloadableMemorySource : IConfigurationSource
|
||||||
{
|
{
|
||||||
public IConfigurationProvider Build(IConfigurationBuilder builder)
|
public IConfigurationProvider Build(IConfigurationBuilder builder)
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,6 @@
|
||||||
<UserSecretsId>aspnetcore-CreateDefaultBuilder-20170424224131</UserSecretsId>
|
<UserSecretsId>aspnetcore-CreateDefaultBuilder-20170424224131</UserSecretsId>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<!-- Temporary until https://github.com/aspnet/IISIntegration/issues/1099 is fixed -->
|
|
||||||
<ItemGroup Condition="'$(OS)' == 'Windows_NT'">
|
|
||||||
<PackageReference Include="Microsoft.AspNetCore.AspNetCoreModule" Version="$(MicrosoftAspNetCoreAspNetCoreModulePackageVersion)" />
|
|
||||||
<PackageReference Include="Microsoft.AspNetCore.AspNetCoreModuleV2" Version="$(MicrosoftAspNetCoreAspNetCoreModuleV2PackageVersion)" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\..\src\Microsoft.AspNetCore\Microsoft.AspNetCore.csproj" />
|
<ProjectReference Include="..\..\..\src\Microsoft.AspNetCore\Microsoft.AspNetCore.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue