├── korebuild-lock.txt
├── korebuild.json
├── CONTRIBUTING.md
├── test
├── Microsoft.Extensions.Logging.Testing.Tests
│ ├── Properties
│ │ └── AssemlyInfo.cs
│ ├── Microsoft.Extensions.Logging.Testing.Tests.csproj
│ └── TestTestOutputHelper.cs
├── Microsoft.Extensions.Logging.Analyzer.Test
│ ├── xunit.runner.json
│ ├── LoggingDiagnosticRunner.cs
│ └── Microsoft.Extensions.Logging.Analyzer.Test.csproj
├── Microsoft.Extensions.Logging.Test
│ ├── Console
│ │ ├── ConsoleContext.cs
│ │ ├── ConsoleSink.cs
│ │ └── TestConsole.cs
│ ├── ProviderAliasAttribute.cs
│ ├── TestLoggerBuilder.cs
│ ├── NullLoggerFactoryTest.cs
│ ├── LogLevelEnumTest.cs
│ ├── LoggerBuilderExtensionsTests.cs
│ ├── Microsoft.Extensions.Logging.Test.csproj
│ ├── LoggingServiceCollectionExtensionsTest.cs
│ ├── TestConfiguration.cs
│ ├── DebugLoggerTest.cs
│ ├── TraceSourceScopeTest.cs
│ ├── TestLoggerProvider.cs
│ ├── LoggerProviderConfigurationFactoryTest.cs
│ ├── NullLoggerTest.cs
│ ├── EventIdTest.cs
│ ├── TraceSourceLoggerProviderTest.cs
│ └── TraceSourceLoggerTest.cs
├── Microsoft.Extensions.Logging.AzureAppServices.Test
│ ├── Microsoft.Extensions.Logging.AzureAppServices.Test.csproj
│ ├── OptionsWrapperMonitor.cs
│ ├── ManualIntervalControl.cs
│ ├── TestBlobSink.cs
│ ├── TestFileLoggerProvider.cs
│ └── WebConfigurationLevelSwitchTests.cs
├── Microsoft.Extensions.Logging.EventSource.Test
│ ├── Microsoft.Extensions.Logging.EventSource.Test.csproj
│ ├── AssemblyInfo.cs
│ └── AzureAppServicesLoggerFactoryExtensionsTests.cs
└── Directory.Build.props
├── NuGet.config
├── run.cmd
├── .vsts-pipelines
└── builds
│ ├── ci-internal.yml
│ └── ci-public.yml
├── samples
└── SampleApp
│ ├── logging.json
│ ├── LoggerExtensions.cs
│ └── SampleApp.csproj
├── src
├── Directory.Build.props
├── Microsoft.Extensions.Logging.Testing
│ ├── BeginScopeContext.cs
│ ├── ShortClassNameAttribute.cs
│ ├── RetryContext.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Xunit
│ │ ├── LogLevelAttribute.cs
│ │ ├── LoggedFactDiscoverer.cs
│ │ ├── LoggedTestFramework.cs
│ │ ├── LoggedTestFrameworkExecutor.cs
│ │ ├── LoggedConditionalFactDiscoverer.cs
│ │ ├── LoggedTheoryDiscoverer.cs
│ │ ├── LoggedTestAssemblyRunner.cs
│ │ ├── LoggedTheoryTestCase.cs
│ │ ├── LoggedTestCase.cs
│ │ ├── LoggedTestMethodRunner.cs
│ │ ├── LoggedTestCollectionRunner.cs
│ │ ├── LoggedTestClassRunner.cs
│ │ ├── LoggedTestCaseRunner.cs
│ │ ├── LoggedTheoryTestCaseRunner.cs
│ │ └── LoggedConditionalTheoryDiscoverer.cs
│ ├── ITestSink.cs
│ ├── TestFrameworkFileLoggerAttribute.cs
│ ├── TestLoggerProvider.cs
│ ├── LoggedTest
│ │ ├── ILoggedTest.cs
│ │ └── LoggedTest.cs
│ ├── WriteContext.cs
│ ├── TestLoggerFactory.cs
│ ├── TestLoggerOfT.cs
│ ├── build
│ │ └── Microsoft.Extensions.Logging.Testing.props
│ ├── Microsoft.Extensions.Logging.Testing.csproj
│ ├── XunitLoggerFactoryExtensions.cs
│ ├── TestLogger.cs
│ └── TestSink.cs
├── Microsoft.Extensions.Logging.Console
│ ├── IConsoleLoggerSettings.cs
│ ├── Internal
│ │ ├── IAnsiSystemConsole.cs
│ │ ├── IConsole.cs
│ │ ├── LogMessageEntry.cs
│ │ └── WindowsLogConsole.cs
│ ├── ConsoleLoggerOptionsSetup.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Microsoft.Extensions.Logging.Console.csproj
│ ├── ConsoleLoggerOptions.cs
│ ├── ConsoleLoggerSettings.cs
│ └── ConsoleLogScope.cs
├── Microsoft.Extensions.Logging
│ ├── Properties
│ │ └── AssemlyInfo.cs
│ ├── DefaultLoggerLevelConfigureOptions.cs
│ ├── LoggingBuilder.cs
│ ├── ILoggingBuilder.cs
│ ├── ProviderAliasAttribute.cs
│ ├── StaticFilterOptionsMonitor.cs
│ ├── Microsoft.Extensions.Logging.csproj
│ ├── LoggerFilterOptions.cs
│ ├── ProviderAliasUtilities.cs
│ ├── LoggingBuilderExtensions.cs
│ ├── LoggerFilterRule.cs
│ ├── LoggingServiceCollectionExtensions.cs
│ └── LoggerInformation.cs
├── Microsoft.Extensions.Logging.AzureAppServices
│ ├── Internal
│ │ ├── LogMessage.cs
│ │ ├── ForwardingLoggerProvider.cs
│ │ ├── SiteConfigurationProvider.cs
│ │ ├── ICloudAppendBlob.cs
│ │ ├── FileLoggerConfigureOptions.cs
│ │ ├── IWebAppContext.cs
│ │ ├── BlobLoggerConfigureOptions.cs
│ │ ├── BatchLoggerConfigureOptions.cs
│ │ ├── WebAppContext.cs
│ │ ├── ConfigurationBasedLevelSwitcher.cs
│ │ └── BatchingLogger.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Microsoft.Extensions.Logging.AzureAppServices.csproj
│ └── AzureBlobLoggerOptions.cs
├── Microsoft.Extensions.Logging.EventLog
│ ├── Internal
│ │ └── IEventLog.cs
│ ├── Microsoft.Extensions.Logging.EventLog.csproj
│ ├── WindowsEventLog.cs
│ ├── EventLogSettings.cs
│ └── EventLogLoggerProvider.cs
├── Microsoft.Extensions.Logging.Configuration
│ ├── LoggingConfiguration.cs
│ ├── Microsoft.Extensions.Logging.Configuration.csproj
│ ├── LoggerProviderOptionsChangeTokenSource.cs
│ ├── LoggerProviderConfiguration.cs
│ ├── ILoggerProviderConfiguration.cs
│ ├── ILoggerProviderConfigurationFactory.cs
│ ├── LoggerProviderConfigureOptions.cs
│ ├── LoggingBuilderConfigurationExtensions.cs
│ ├── LoggerProviderConfigurationExtensions.cs
│ ├── LoggingBuilderExtensions.cs
│ └── LoggerProviderConfigurationFactory.cs
├── Microsoft.Extensions.Logging.Debug
│ ├── Microsoft.Extensions.Logging.Debug.csproj
│ ├── DebugLogger.debug.cs
│ ├── DebugLoggerProvider.cs
│ └── DebugLoggerFactoryExtensions.cs
├── Microsoft.Extensions.Logging.Abstractions
│ ├── Properties
│ │ ├── AssemblyInfo.cs
│ │ └── Resource.Designer.cs
│ ├── Internal
│ │ └── NullScope.cs
│ ├── Microsoft.Extensions.Logging.Abstractions.csproj
│ ├── ISupportExternalScope.cs
│ ├── ILoggerOfT.cs
│ ├── ILoggerProvider.cs
│ ├── NullLoggerProvider.cs
│ ├── ILoggerFactory.cs
│ ├── NullLogger.cs
│ ├── NullLoggerFactory.cs
│ ├── IExternalScopeProvider.cs
│ ├── EventId.cs
│ ├── NullLoggerOfT.cs
│ ├── LoggerOfT.cs
│ ├── LoggerFactoryExtensions.cs
│ ├── ILogger.cs
│ ├── LogLevel.cs
│ └── LoggerExternalScopeProvider.cs
├── Microsoft.Extensions.Logging.EventSource
│ ├── Microsoft.Extensions.Logging.EventSource.csproj
│ ├── ExceptionInfo.cs
│ ├── EventLogFiltersConfigureOptionsChangeSource.cs
│ ├── EventLogFiltersConfigureOptions.cs
│ └── EventSourceLoggerFactoryExtensions.cs
├── Microsoft.Extensions.Logging.TraceSource
│ ├── Microsoft.Extensions.Logging.TraceSource.csproj
│ └── TraceSourceScope.cs
└── Microsoft.Extensions.Logging.Analyzers
│ ├── Microsoft.Extensions.Logging.Analyzers.csproj
│ └── Descriptors.cs
├── .appveyor.yml
├── .gitignore
├── NuGetPackageVerifier.json
├── .travis.yml
├── Directory.Build.targets
├── benchmarks
└── Logging.Performance
│ ├── Logging.Performance.csproj
│ ├── LoggingBenchmarkBase.cs
│ └── LogValuesBenchmarks.cs
├── Directory.Build.props
├── .gitattributes
├── README.md
└── version.props
/korebuild-lock.txt:
--------------------------------------------------------------------------------
1 | version:3.0.0-alpha1-20181004.7
2 | commithash:27fabdaf2b1d4753c3d2749581694ca65d78f7f2
3 |
--------------------------------------------------------------------------------
/korebuild.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/master/tools/korebuild.schema.json",
3 | "channel": "master"
4 | }
5 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | Contributing
2 | ======
3 |
4 | Information on contributing to this repo is in the [Contributing Guide](https://github.com/aspnet/Home/blob/master/CONTRIBUTING.md) in the Home repo.
5 |
--------------------------------------------------------------------------------
/test/Microsoft.Extensions.Logging.Testing.Tests/Properties/AssemlyInfo.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Extensions.Logging;
2 | using Microsoft.Extensions.Logging.Testing;
3 |
4 | [assembly: LogLevel(LogLevel.Trace)]
5 |
--------------------------------------------------------------------------------
/NuGet.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/test/Microsoft.Extensions.Logging.Analyzer.Test/xunit.runner.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json.schemastore.org/xunit.runner.schema",
3 | "appDomain": "denied",
4 | "methodDisplay": "method",
5 | "longRunningTestSeconds": 60
6 | }
7 |
--------------------------------------------------------------------------------
/run.cmd:
--------------------------------------------------------------------------------
1 | @ECHO OFF
2 | PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0run.ps1' %*; exit $LASTEXITCODE"
3 |
--------------------------------------------------------------------------------
/.vsts-pipelines/builds/ci-internal.yml:
--------------------------------------------------------------------------------
1 | trigger:
2 | - master
3 | - release/*
4 |
5 | resources:
6 | repositories:
7 | - repository: buildtools
8 | type: git
9 | name: aspnet-BuildTools
10 | ref: refs/heads/master
11 |
12 | phases:
13 | - template: .vsts-pipelines/templates/project-ci.yml@buildtools
14 |
--------------------------------------------------------------------------------
/samples/SampleApp/logging.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Debug",
5 | "System": "Information",
6 | "Microsoft": "Information"
7 | },
8 | "Console":
9 | {
10 | "IncludeScopes": "true",
11 | "TimestampFormat": "[HH:mm:ss] ",
12 | "LogToStandardErrorThreshold": "Warning"
13 | }
14 | }
15 | }
--------------------------------------------------------------------------------
/.vsts-pipelines/builds/ci-public.yml:
--------------------------------------------------------------------------------
1 | trigger:
2 | - master
3 | - release/*
4 |
5 | # See https://github.com/aspnet/BuildTools
6 | resources:
7 | repositories:
8 | - repository: buildtools
9 | type: github
10 | endpoint: DotNet-Bot GitHub Connection
11 | name: aspnet/BuildTools
12 | ref: refs/heads/master
13 |
14 | phases:
15 | - template: .vsts-pipelines/templates/project-ci.yml@buildtools
16 |
--------------------------------------------------------------------------------
/src/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | true
6 | logging
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.Logging.Testing/BeginScopeContext.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | namespace Microsoft.Extensions.Logging.Testing
5 | {
6 | public class BeginScopeContext
7 | {
8 | public object Scope { get; set; }
9 |
10 | public string LoggerName { get; set; }
11 | }
12 | }
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.Logging.Console/IConsoleLoggerSettings.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.Extensions.Primitives;
3 |
4 | namespace Microsoft.Extensions.Logging.Console
5 | {
6 | public interface IConsoleLoggerSettings
7 | {
8 | bool IncludeScopes { get; }
9 |
10 | IChangeToken ChangeToken { get; }
11 |
12 | bool TryGetSwitch(string name, out LogLevel level);
13 |
14 | IConsoleLoggerSettings Reload();
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.Logging.Console/Internal/IAnsiSystemConsole.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | namespace Microsoft.Extensions.Logging.Console.Internal
5 | {
6 | public interface IAnsiSystemConsole
7 | {
8 | void Write(string message);
9 |
10 | void WriteLine(string message);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/.appveyor.yml:
--------------------------------------------------------------------------------
1 | init:
2 | - git config --global core.autocrlf true
3 | branches:
4 | only:
5 | - master
6 | - /^release\/.*$/
7 | - /^(.*\/)?ci-.*$/
8 | build_script:
9 | - ps: .\run.ps1 default-build
10 | clone_depth: 1
11 | environment:
12 | global:
13 | DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
14 | DOTNET_CLI_TELEMETRY_OPTOUT: 1
15 | ASPNETCORE_TEST_LOG_DIR: $APPVEYOR_BUILD_FOLDER\artifacts\logs
16 | test: 'off'
17 | deploy: 'off'
18 | os: Visual Studio 2017
19 |
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.Logging/Properties/AssemlyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.CompilerServices;
2 |
3 | [assembly: InternalsVisibleTo("Microsoft.Extensions.Logging.Configuration, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | [Oo]bj/
2 | [Bb]in/
3 | TestResults/
4 | .nuget/
5 | _ReSharper.*/
6 | packages/
7 | artifacts/
8 | PublishProfiles/
9 | *.user
10 | *.suo
11 | *.cache
12 | *.docstates
13 | _ReSharper.*
14 | nuget.exe
15 | *net45.csproj
16 | *net451.csproj
17 | *k10.csproj
18 | *.psess
19 | *.vsp
20 | *.pidb
21 | *.userprefs
22 | *DS_Store
23 | *.ncrunchsolution
24 | *.*sdf
25 | *.ipch
26 | *.sln.ide
27 | project.lock.json
28 | .vs
29 | .build/
30 | .testPublish/
31 | global.json
32 | BenchmarkDotNet.Artifacts/
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.Logging.AzureAppServices/Internal/LogMessage.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 |
6 | namespace Microsoft.Extensions.Logging.AzureAppServices.Internal
7 | {
8 | public struct LogMessage
9 | {
10 | public DateTimeOffset Timestamp { get; set; }
11 | public string Message { get; set; }
12 | }
13 | }
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.Logging.Testing/ShortClassNameAttribute.cs:
--------------------------------------------------------------------------------
1 | // Copyright(c) .NET Foundation.All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 |
6 | namespace Microsoft.Extensions.Logging.Testing
7 | {
8 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = false)]
9 | public class ShortClassNameAttribute : Attribute
10 | {
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/NuGetPackageVerifier.json:
--------------------------------------------------------------------------------
1 | {
2 | "Default": {
3 | "rules": [
4 | "DefaultCompositeRule"
5 | ],
6 | "packages": {
7 | "Microsoft.Extensions.Logging.Testing": {
8 | "Exclusions": {
9 | "BUILD_ITEMS_FRAMEWORK": {
10 | "*": "Props file intentionally targets any framework since the content is the same for both netstandard2.0 and net461."
11 | }
12 | }
13 | }
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.Logging.EventLog/Internal/IEventLog.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System.Diagnostics;
5 |
6 | namespace Microsoft.Extensions.Logging.EventLog.Internal
7 | {
8 | public interface IEventLog
9 | {
10 | int MaxMessageSize { get; }
11 |
12 | void WriteEntry(string message, EventLogEntryType type, int eventID, short category);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/test/Microsoft.Extensions.Logging.Test/Console/ConsoleContext.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 |
6 | namespace Microsoft.Extensions.Logging.Test.Console
7 | {
8 | public class ConsoleContext
9 | {
10 | public ConsoleColor? BackgroundColor { get; set; }
11 |
12 | public ConsoleColor? ForegroundColor { get; set; }
13 |
14 | public string Message { get; set; }
15 | }
16 | }
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.Logging.Console/Internal/IConsole.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 |
6 | namespace Microsoft.Extensions.Logging.Console.Internal
7 | {
8 | public interface IConsole
9 | {
10 | void Write(string message, ConsoleColor? background, ConsoleColor? foreground);
11 | void WriteLine(string message, ConsoleColor? background, ConsoleColor? foreground);
12 | void Flush();
13 | }
14 | }
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.Logging.Testing/RetryContext.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 |
6 | namespace Microsoft.Extensions.Logging.Testing
7 | {
8 | public class RetryContext
9 | {
10 | internal int Limit { get; set; }
11 |
12 | internal object TestClassInstance { get; set; }
13 |
14 | internal string Reason { get; set; }
15 |
16 | internal int CurrentIteration { get; set; }
17 | }
18 | }
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.Logging.Console/ConsoleLoggerOptionsSetup.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Extensions.Configuration;
2 | using Microsoft.Extensions.Logging.Configuration;
3 | using Microsoft.Extensions.Options;
4 |
5 | namespace Microsoft.Extensions.Logging.Console
6 | {
7 | internal class ConsoleLoggerOptionsSetup : ConfigureFromConfigurationOptions
8 | {
9 | public ConsoleLoggerOptionsSetup(ILoggerProviderConfiguration providerConfiguration)
10 | : base(providerConfiguration.Configuration)
11 | {
12 | }
13 | }
14 | }
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.Logging/DefaultLoggerLevelConfigureOptions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using Microsoft.Extensions.Options;
5 |
6 | namespace Microsoft.Extensions.Logging
7 | {
8 | internal class DefaultLoggerLevelConfigureOptions : ConfigureOptions
9 | {
10 | public DefaultLoggerLevelConfigureOptions(LogLevel level) : base(options => options.MinLevel = level)
11 | {
12 | }
13 | }
14 | }
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.Logging/LoggingBuilder.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using Microsoft.Extensions.DependencyInjection;
5 |
6 | namespace Microsoft.Extensions.Logging
7 | {
8 | internal class LoggingBuilder : ILoggingBuilder
9 | {
10 | public LoggingBuilder(IServiceCollection services)
11 | {
12 | Services = services;
13 | }
14 |
15 | public IServiceCollection Services { get; }
16 | }
17 | }
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.Logging.Configuration/LoggingConfiguration.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using Microsoft.Extensions.Configuration;
5 |
6 | namespace Microsoft.Extensions.Logging.Configuration
7 | {
8 | internal class LoggingConfiguration
9 | {
10 | public IConfiguration Configuration { get; }
11 |
12 | public LoggingConfiguration(IConfiguration configuration)
13 | {
14 | Configuration = configuration;
15 | }
16 | }
17 | }
--------------------------------------------------------------------------------
/test/Microsoft.Extensions.Logging.Test/Console/ConsoleSink.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 | using System.Collections.Generic;
6 |
7 | namespace Microsoft.Extensions.Logging.Test.Console
8 | {
9 | public class ConsoleSink
10 | {
11 | public List Writes { get; set; } = new List();
12 |
13 | public void Write(ConsoleContext context)
14 | {
15 | Writes.Add(context);
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.Logging.Debug/Microsoft.Extensions.Logging.Debug.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug output logger provider implementation for Microsoft.Extensions.Logging. This logger logs messages to a debugger monitor by writing messages with System.Diagnostics.Debug.WriteLine().
5 | netstandard2.0
6 | $(NoWarn);CS1591
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/test/Microsoft.Extensions.Logging.AzureAppServices.Test/Microsoft.Extensions.Logging.AzureAppServices.Test.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(StandardTestTfms)
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.Logging.Abstractions/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System.Runtime.CompilerServices;
5 |
6 | [assembly: InternalsVisibleTo("Microsoft.Extensions.Logging.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.Logging.Console/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System.Runtime.CompilerServices;
5 |
6 |
7 | [assembly: InternalsVisibleTo("Microsoft.Extensions.Logging.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
--------------------------------------------------------------------------------
/test/Microsoft.Extensions.Logging.EventSource.Test/Microsoft.Extensions.Logging.EventSource.Test.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(StandardTestTfms)
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.Logging.Testing/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System.Runtime.CompilerServices;
5 |
6 | [assembly: InternalsVisibleTo("Microsoft.Extensions.Logging.Testing.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
7 |
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.Logging.Console/Internal/LogMessageEntry.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 |
6 | namespace Microsoft.Extensions.Logging.Console.Internal
7 | {
8 | public struct LogMessageEntry
9 | {
10 | public string TimeStamp;
11 | public string LevelString;
12 | public ConsoleColor? LevelBackground;
13 | public ConsoleColor? LevelForeground;
14 | public ConsoleColor? MessageColor;
15 | public string Message;
16 | public bool LogAsError;
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.Logging.Testing/Xunit/LogLevelAttribute.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 |
6 | namespace Microsoft.Extensions.Logging.Testing
7 | {
8 | [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = false)]
9 | public class LogLevelAttribute : Attribute
10 | {
11 | public LogLevelAttribute(LogLevel logLevel)
12 | {
13 | LogLevel = logLevel;
14 | }
15 |
16 | public LogLevel LogLevel { get; }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.Logging/ILoggingBuilder.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using Microsoft.Extensions.DependencyInjection;
5 |
6 | namespace Microsoft.Extensions.Logging
7 | {
8 | ///
9 | /// An interface for configuring logging providers.
10 | ///
11 | public interface ILoggingBuilder
12 | {
13 | ///
14 | /// Gets the where Logging services are configured.
15 | ///
16 | IServiceCollection Services { get; }
17 | }
18 | }
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.Logging.AzureAppServices/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System.Runtime.CompilerServices;
5 |
6 |
7 | [assembly: InternalsVisibleTo("Microsoft.Extensions.Logging.AzureAppServices.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
--------------------------------------------------------------------------------
/test/Microsoft.Extensions.Logging.Test/ProviderAliasAttribute.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 |
6 | namespace Microsoft.Extensions.Logging
7 | {
8 | ///
9 | /// Test implementation of ProviderAliasAttribute
10 | ///
11 | [AttributeUsage(AttributeTargets.Class)]
12 | public class ProviderAliasAttribute : Attribute
13 | {
14 | public ProviderAliasAttribute(string alias)
15 | {
16 | Alias = alias;
17 | }
18 |
19 | public string Alias { get; }
20 | }
21 | }
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.Logging.Configuration/Microsoft.Extensions.Logging.Configuration.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Configuration support for Microsoft.Extensions.Logging.
5 | netstandard2.0
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.Logging.EventSource/Microsoft.Extensions.Logging.EventSource.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | EventSource/EventListener logger provider implementation for Microsoft.Extensions.Logging.
5 | netstandard2.0
6 | $(PackageTags);EventSource;ETW
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/test/Microsoft.Extensions.Logging.EventSource.Test/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using Xunit;
5 |
6 | // There can only be one EventSource per AppDomain, and when an event is raised through that EventSource,
7 | // all existing listeners that enabled that EventSource will receive the event.
8 | // This makes running EventSourceLogger tests in parallel difficult. We mark this assembly
9 | // with CollectionBehavior.CollectionPerAssembly to ensure that all tests in this assembly are executed serially.
10 | [assembly: CollectionBehavior(CollectionBehavior.CollectionPerAssembly)]
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.Logging.Abstractions/Internal/NullScope.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 |
6 | namespace Microsoft.Extensions.Logging.Abstractions.Internal
7 | {
8 | ///
9 | /// An empty scope without any logic
10 | ///
11 | public class NullScope : IDisposable
12 | {
13 | public static NullScope Instance { get; } = new NullScope();
14 |
15 | private NullScope()
16 | {
17 | }
18 |
19 | ///
20 | public void Dispose()
21 | {
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: csharp
2 | sudo: false
3 | dist: trusty
4 | env:
5 | global:
6 | - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
7 | - DOTNET_CLI_TELEMETRY_OPTOUT: 1
8 | - ASPNETCORE_TEST_LOG_DIR: $APPVEYOR_BUILD_FOLDER\artifacts\logs
9 | mono: none
10 | os:
11 | - linux
12 | - osx
13 | osx_image: xcode8.2
14 | addons:
15 | apt:
16 | packages:
17 | - libunwind8
18 | branches:
19 | only:
20 | - master
21 | - /^release\/.*$/
22 | - /^(.*\/)?ci-.*$/
23 | before_install:
24 | - if test "$TRAVIS_OS_NAME" == "osx"; then brew update; brew install openssl; ln -s
25 | /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/; ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
26 | /usr/local/lib/; fi
27 | script:
28 | - ./build.sh
29 |
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.Logging.Abstractions/Microsoft.Extensions.Logging.Abstractions.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Logging abstractions for Microsoft.Extensions.Logging.
5 | Commonly used types:
6 | Microsoft.Extensions.Logging.ILogger
7 | Microsoft.Extensions.Logging.ILoggerFactory
8 | Microsoft.Extensions.Logging.ILogger<TCategoryName>
9 | Microsoft.Extensions.Logging.LogLevel
10 | Microsoft.Extensions.Logging.Logger<T>
11 | Microsoft.Extensions.Logging.LoggerMessage
12 | Microsoft.Extensions.Logging.Abstractions.NullLogger
13 | netstandard2.0
14 | $(NoWarn);CS1591
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.Logging.Configuration/LoggerProviderOptionsChangeTokenSource.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using Microsoft.Extensions.Options;
5 |
6 | namespace Microsoft.Extensions.Logging.Configuration
7 | {
8 | ///
9 | public class LoggerProviderOptionsChangeTokenSource : ConfigurationChangeTokenSource
10 | {
11 | ///
12 | public LoggerProviderOptionsChangeTokenSource(ILoggerProviderConfiguration providerConfiguration) : base(providerConfiguration.Configuration)
13 | {
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.Logging.Debug/DebugLogger.debug.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | // We need to define the DEBUG symbol because we want the logger
5 | // to work even when this package is compiled on release. Otherwise,
6 | // the call to Debug.WriteLine will not be in the release binary
7 | #define DEBUG
8 |
9 | namespace Microsoft.Extensions.Logging.Debug
10 | {
11 | public partial class DebugLogger
12 | {
13 | private void DebugWriteLine(string message, string name)
14 | {
15 | System.Diagnostics.Debug.WriteLine(message, category: name);
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.Logging.Abstractions/ISupportExternalScope.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | namespace Microsoft.Extensions.Logging
5 | {
6 | ///
7 | /// Represents a that is able to consume external scope information.
8 | ///
9 | public interface ISupportExternalScope
10 | {
11 | ///
12 | /// Sets external scope information source for logger provider.
13 | ///
14 | ///
15 | void SetScopeProvider(IExternalScopeProvider scopeProvider);
16 | }
17 | }
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.Logging.Configuration/LoggerProviderConfiguration.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using Microsoft.Extensions.Configuration;
5 |
6 | namespace Microsoft.Extensions.Logging.Configuration
7 | {
8 | internal class LoggerProviderConfiguration : ILoggerProviderConfiguration
9 | {
10 | public LoggerProviderConfiguration(ILoggerProviderConfigurationFactory providerConfigurationFactory)
11 | {
12 | Configuration = providerConfigurationFactory.GetConfiguration(typeof(T));
13 | }
14 |
15 | public IConfiguration Configuration { get; }
16 | }
17 | }
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.Logging.Testing/ITestSink.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Concurrent;
3 |
4 | namespace Microsoft.Extensions.Logging.Testing
5 | {
6 | public interface ITestSink
7 | {
8 | event Action MessageLogged;
9 |
10 | event Action ScopeStarted;
11 |
12 | Func WriteEnabled { get; set; }
13 |
14 | Func BeginEnabled { get; set; }
15 |
16 | IProducerConsumerCollection Scopes { get; set; }
17 |
18 | IProducerConsumerCollection Writes { get; set; }
19 |
20 | void Write(WriteContext context);
21 |
22 | void Begin(BeginScopeContext context);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/test/Microsoft.Extensions.Logging.Test/TestLoggerBuilder.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 | using Castle.Core.Logging;
6 | using Microsoft.Extensions.DependencyInjection;
7 |
8 | namespace Microsoft.Extensions.Logging.Test
9 | {
10 | public static class TestLoggerBuilder
11 | {
12 | public static ILoggerFactory Create(Action configure)
13 | {
14 | return new ServiceCollection()
15 | .AddLogging(configure)
16 | .BuildServiceProvider()
17 | .GetRequiredService();
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.Logging.Testing/TestFrameworkFileLoggerAttribute.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 |
6 | namespace Microsoft.Extensions.Logging.Testing
7 | {
8 | [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)]
9 | public class TestFrameworkFileLoggerAttribute : Attribute
10 | {
11 | public TestFrameworkFileLoggerAttribute(string tfm, string baseDirectory = null)
12 | {
13 | TFM = tfm;
14 | BaseDirectory = baseDirectory;
15 | }
16 |
17 | public string TFM { get; }
18 | public string BaseDirectory { get; }
19 | }
20 | }
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.Logging.Testing/TestLoggerProvider.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | namespace Microsoft.Extensions.Logging.Testing
5 | {
6 | public class TestLoggerProvider : ILoggerProvider
7 | {
8 | private readonly ITestSink _sink;
9 |
10 | public TestLoggerProvider(ITestSink sink)
11 | {
12 | _sink = sink;
13 | }
14 |
15 | public ILogger CreateLogger(string categoryName)
16 | {
17 | return new TestLogger(categoryName, _sink, enabled: true);
18 | }
19 |
20 | public void Dispose()
21 | {
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.Logging/ProviderAliasAttribute.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 |
6 | namespace Microsoft.Extensions.Logging
7 | {
8 | ///
9 | /// Defines alias for implementation to be used in filtering rules.
10 | ///
11 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
12 | public class ProviderAliasAttribute: Attribute
13 | {
14 | public ProviderAliasAttribute(string alias)
15 | {
16 | Alias = alias;
17 | }
18 |
19 | public string Alias { get; }
20 |
21 | }
22 | }
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.Logging.TraceSource/Microsoft.Extensions.Logging.TraceSource.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | TraceSource logger provider implementation for Microsoft.Extensions.Logging. This logger logs messages to a trace listener by writing messages with System.Diagnostics.TraceSource.TraceEvent().
5 | netstandard2.0
6 | $(NoWarn);CS1591
7 | true
8 | logging;tracesource
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.Logging.EventLog/Microsoft.Extensions.Logging.EventLog.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Windows Event Log logger provider implementation for Microsoft.Extensions.Logging.
5 | netstandard2.0;net461
6 | $(NoWarn);CS1591
7 | $(PackageTags);eventlog;windowseventlog
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.Logging.EventSource/ExceptionInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | namespace Microsoft.Extensions.Logging.EventSource
5 | {
6 | ///
7 | /// Represents information about exceptions that is captured by EventSourceLogger
8 | ///
9 | [System.Diagnostics.Tracing.EventData(Name ="ExceptionInfo")]
10 | internal class ExceptionInfo
11 | {
12 | public string TypeName { get; set; }
13 | public string Message { get; set; }
14 | public int HResult { get; set; }
15 | public string VerboseMessage { get; set; } // This is the ToString() of the Exception
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/test/Microsoft.Extensions.Logging.Test/NullLoggerFactoryTest.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using Xunit;
5 |
6 | namespace Microsoft.Extensions.Logging.Abstractions
7 | {
8 | public class NullLoggerFactoryTest
9 | {
10 | [Fact]
11 | public void Create_GivesSameLogger()
12 | {
13 | // Arrange
14 | var factory = NullLoggerFactory.Instance;
15 |
16 | // Act
17 | var logger1 = factory.CreateLogger("Logger1");
18 | var logger2 = factory.CreateLogger("Logger2");
19 |
20 | // Assert
21 | Assert.Same(logger1, logger2);
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/test/Microsoft.Extensions.Logging.Testing.Tests/Microsoft.Extensions.Logging.Testing.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | $(StandardTestTfms)
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.Logging.Abstractions/ILoggerOfT.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 |
6 | namespace Microsoft.Extensions.Logging
7 | {
8 | ///
9 | /// A generic interface for logging where the category name is derived from the specified
10 | /// type name.
11 | /// Generally used to enable activation of a named from dependency injection.
12 | ///
13 | /// The type who's name is used for the logger category name.
14 | public interface ILogger : ILogger
15 | {
16 |
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.Logging.Abstractions/ILoggerProvider.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 |
6 | namespace Microsoft.Extensions.Logging
7 | {
8 | ///
9 | /// Represents a type that can create instances of .
10 | ///
11 | public interface ILoggerProvider : IDisposable
12 | {
13 | ///
14 | /// Creates a new instance.
15 | ///
16 | /// The category name for messages produced by the logger.
17 | ///
18 | ILogger CreateLogger(string categoryName);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.Logging.Configuration/ILoggerProviderConfiguration.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using Microsoft.Extensions.Configuration;
5 |
6 | namespace Microsoft.Extensions.Logging.Configuration
7 | {
8 | ///
9 | /// Allows access to configuration section associated with logger provider
10 | ///
11 | /// Type of logger provider to get configuration for
12 | public interface ILoggerProviderConfiguration
13 | {
14 | ///
15 | /// Configuration section for requested logger provider
16 | ///
17 | IConfiguration Configuration { get; }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/test/Microsoft.Extensions.Logging.AzureAppServices.Test/OptionsWrapperMonitor.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 | using Microsoft.Extensions.Options;
6 |
7 | namespace Microsoft.Extensions.Logging.AzureAppServices.Test
8 | {
9 | internal class OptionsWrapperMonitor : IOptionsMonitor
10 | {
11 | public OptionsWrapperMonitor(T currentValue)
12 | {
13 | CurrentValue = currentValue;
14 | }
15 |
16 | public IDisposable OnChange(Action listener)
17 | {
18 | return null;
19 | }
20 |
21 | public T Get(string name) => CurrentValue;
22 |
23 | public T CurrentValue { get; }
24 | }
25 | }
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.Logging/StaticFilterOptionsMonitor.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 | using Microsoft.Extensions.Options;
6 |
7 | namespace Microsoft.Extensions.Logging
8 | {
9 | internal class StaticFilterOptionsMonitor : IOptionsMonitor
10 | {
11 | public StaticFilterOptionsMonitor(LoggerFilterOptions currentValue)
12 | {
13 | CurrentValue = currentValue;
14 | }
15 |
16 | public IDisposable OnChange(Action listener) => null;
17 |
18 | public LoggerFilterOptions Get(string name) => CurrentValue;
19 |
20 | public LoggerFilterOptions CurrentValue { get; }
21 | }
22 | }
--------------------------------------------------------------------------------
/Directory.Build.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 | $(MicrosoftNETCoreApp20PackageVersion)
4 | $(MicrosoftNETCoreApp21PackageVersion)
5 | $(MicrosoftNETCoreApp22PackageVersion)
6 | $(NETStandardLibrary20PackageVersion)
7 |
8 | 99.9
9 |
10 |
11 |
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.Logging.Testing/Xunit/LoggedFactDiscoverer.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using Xunit.Abstractions;
5 | using Xunit.Sdk;
6 |
7 | namespace Microsoft.Extensions.Logging.Testing
8 | {
9 | public class LoggedFactDiscoverer : FactDiscoverer
10 | {
11 | public LoggedFactDiscoverer(IMessageSink diagnosticMessageSink) : base(diagnosticMessageSink)
12 | {
13 | }
14 |
15 | protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute)
16 | => new LoggedTestCase(DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.Logging.Configuration/ILoggerProviderConfigurationFactory.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 | using Microsoft.Extensions.Configuration;
6 |
7 | namespace Microsoft.Extensions.Logging.Configuration
8 | {
9 | ///
10 | /// Allows access to configuration section associated with logger provider
11 | ///
12 | public interface ILoggerProviderConfigurationFactory
13 | {
14 | ///
15 | /// Return configuration section associated with logger provider
16 | ///
17 | /// The logger provider type
18 | IConfiguration GetConfiguration(Type providerType);
19 | }
20 | }
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.Logging.Configuration/LoggerProviderConfigureOptions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using Microsoft.Extensions.Options;
5 |
6 | namespace Microsoft.Extensions.Logging.Configuration
7 | {
8 | ///
9 | /// Loads settings for into type.
10 | ///
11 | internal class LoggerProviderConfigureOptions : ConfigureFromConfigurationOptions where TOptions : class
12 | {
13 | public LoggerProviderConfigureOptions(ILoggerProviderConfiguration providerConfiguration)
14 | : base(providerConfiguration.Configuration)
15 | {
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.Logging.Console/Microsoft.Extensions.Logging.Console.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Console logger provider implementation for Microsoft.Extensions.Logging.
5 | netstandard2.0
6 | $(NoWarn);CS1591
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.Logging.Testing/LoggedTest/ILoggedTest.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 | using System.Reflection;
6 | using Xunit.Abstractions;
7 |
8 | namespace Microsoft.Extensions.Logging.Testing
9 | {
10 | public interface ILoggedTest : IDisposable
11 | {
12 | ILogger Logger { get; }
13 |
14 | ILoggerFactory LoggerFactory { get; }
15 |
16 | ITestOutputHelper TestOutputHelper { get; }
17 |
18 | // For back compat
19 | IDisposable StartLog(out ILoggerFactory loggerFactory, LogLevel minLogLevel, string testName);
20 |
21 | void Initialize(MethodInfo methodInfo, object[] testMethodArguments, ITestOutputHelper testOutputHelper);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.Logging.AzureAppServices/Internal/ForwardingLoggerProvider.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | namespace Microsoft.Extensions.Logging.AzureAppServices.Internal
5 | {
6 | internal class ForwardingLoggerProvider : ILoggerProvider
7 | {
8 | private readonly ILoggerFactory _loggerFactory;
9 |
10 | public ForwardingLoggerProvider(ILoggerFactory loggerFactory)
11 | {
12 | _loggerFactory = loggerFactory;
13 | }
14 |
15 | public void Dispose()
16 | {
17 | _loggerFactory.Dispose();
18 | }
19 |
20 | public ILogger CreateLogger(string categoryName)
21 | {
22 | return _loggerFactory.CreateLogger(categoryName);
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.Logging.Abstractions/NullLoggerProvider.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | namespace Microsoft.Extensions.Logging.Abstractions
5 | {
6 | ///
7 | /// Provider for the .
8 | ///
9 | public class NullLoggerProvider : ILoggerProvider
10 | {
11 | public static NullLoggerProvider Instance { get; } = new NullLoggerProvider();
12 |
13 | private NullLoggerProvider()
14 | {
15 | }
16 |
17 | ///
18 | public ILogger CreateLogger(string categoryName)
19 | {
20 | return NullLogger.Instance;
21 | }
22 |
23 | ///
24 | public void Dispose()
25 | {
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.Logging.Testing/WriteContext.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 |
6 | namespace Microsoft.Extensions.Logging.Testing
7 | {
8 | public class WriteContext
9 | {
10 | public LogLevel LogLevel { get; set; }
11 |
12 | public EventId EventId { get; set; }
13 |
14 | public object State { get; set; }
15 |
16 | public Exception Exception { get; set; }
17 |
18 | public Func