Skip to content

Instantly share code, notes, and snippets.

Avatar
🕸️
Bugfixing

Maryam Ariyan maryamariyan

🕸️
Bugfixing
  • Vancouver, Canada
View GitHub Profile
View NuGet.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!-- NOTE: Leave this file here and keep it in sync with list in dir.props. -->
<!-- The command-line doesn't need it, but the IDE does. -->
<packageSources>
<clear/>
<add key="myget.org dotnet-core" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>
View custom formatter
public class CustomConsoleLogFormatterOptions
{
public string ExtraCustomProperty { get; set; }
}
internal class CustomConsoleLogFormatterOptionsSetup : ConfigureFromConfigurationOptions<CustomConsoleLogFormatterOptions>
{
public CustomConsoleLogFormatterOptionsSetup(ILoggerProviderConfiguration<CustomConsoleLogFormatter>
providerConfiguration)
: base(providerConfiguration.Configuration)
View Sample.cs
namespace ConsoleApp46
{
class Program
{
public static async Task Main(string[] args)
{
using var loggerFactory = LoggerFactory.Create(builder =>
{
builder
// current usage which is to be changed:
@maryamariyan
maryamariyan / CustomFormatter.cs
Last active Nov 27, 2020
custom formatter implementation template
View CustomFormatter.cs
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Logging.Console;
using Microsoft.Extensions.Options;
using System;
using System.IO;
namespace ConsoleApp46
{
public class CustomFormatter : ConsoleFormatter, IDisposable
View FilterSpecsSample.cs
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Console;
using Microsoft.Extensions.Logging.EventSource;
using System;
using System.Diagnostics.Tracing;
using System.Threading;
using System.Threading.Tasks;
namespace ConsoleApp46
{
class Program
View IncreaseLoggingOnOneCategoryUsingFilterSpecs.cs
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.EventSource;
using System;
using System.Collections.Generic;
using System.Diagnostics.Tracing;
using System.Threading;
using System.Threading.Tasks;
namespace ConsoleApp46
{
class Program
View Error1.cs
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.EventSource;
using System;
using System.Collections.Generic;
using System.Diagnostics.Tracing;
using System.Threading;
using System.Threading.Tasks;
namespace ConsoleApp46
{
class Program
View UseFilterSpecsToChangeLogLevels.cs
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.EventSource;
using System;
using System.Collections.Generic;
using System.Diagnostics.Tracing;
using System.Threading;
using System.Threading.Tasks;
namespace ConsoleApp46
{
class Program
View UseAppFiltersUseCase.cs
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.EventSource;
using System;
using System.Collections.Generic;
using System.Diagnostics.Tracing;
using System.Threading;
using System.Threading.Tasks;
namespace ConsoleApp46
{
View Docs.txt
What is a console log formatter?
What are the in-box console log formatters?
Simple
JSON
SystemD
Compact
How do register a new formatter?
How do I select which formatter to use (via both code and config)?
How do I author a new formatter?