Main Method

Using Statements

using Library.Controller;
using Library.Model;
using Serilog;
using Serilog.Events;
using Serilog.Sinks.SystemConsole.Themes;

Create a static async task Main with string[] args

private static async Task Main(string[] args)

create a logger template

Serilog Templates

Serilog provides different options for message templates, which allow you to format log messages in a flexible way. Some of the template options that can be used in message templates include:

  • {Timestamp}: The timestamp of the logging event.

  • {Level}: The logging level of the event (e.g. Information, Warning, Error).

  • {Message}: The message of the logging event.

  • {Exception}: The exception associated with the logging event.

  • {SourceContext}: The name of the logger that generated the event.

  • {Properties}: A collection of all the properties associated with the logging event.

In addition to these built-in properties, you can also include custom properties in your message templates. You can include formatting options in your message templates, such as:

  • {Timestamp:yyyy-MM-dd HH:mm:ss.fff}: Formats the timestamp as a string in the specified format.

  • {Level:u3}: Formats the logging level as a string in uppercase with a minimum width of 3 characters.

Create custom serilog styles

Create Logger

This creates a logger with the specified template and theme, sets the minimum log level based on applications configured release mode. See: PreProcessor Statements

Now create a variable for path and set it to the zeroth argument and if the application is in debug mode it adds console input, you can change this if you would like.

Calls

Finally make the calls to FileSystemController

and reset the console's color

Overview

Last updated

Was this helpful?