Skip to content

Instantly share code, notes, and snippets.

View maryamariyan's full-sized avatar
:octocat:

Maryam Ariyan maryamariyan

:octocat:
View GitHub Profile
<?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>
public class CustomConsoleLogFormatterOptions
{
public string ExtraCustomProperty { get; set; }
}
internal class CustomConsoleLogFormatterOptionsSetup : ConfigureFromConfigurationOptions<CustomConsoleLogFormatterOptions>
{
public CustomConsoleLogFormatterOptionsSetup(ILoggerProviderConfiguration<CustomConsoleLogFormatter>
providerConfiguration)
: base(providerConfiguration.Configuration)
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 November 27, 2020 01:19
custom formatter implementation template
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
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
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
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
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
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
{
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?