Skip to content

Extension destination for TacitusLogger that sends logs to System.Diagnostics.Trace listeners.

License

Notifications You must be signed in to change notification settings

hanlarmammadov/TacitusLogger.Destinations.Trace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TacitusLogger.Destinations.Trace

Extension destination for TacitusLogger that sends logs to System.Diagnostics.Trace listeners.

Dependencies:

  • .Net Standard >=2.0
  • TacitusLogger >=0.1.0

Attention: TacitusLogger.Destinations.Trace is currently in Alpha phase. This means you should not use it in any production code.

Installation

The NuGet package:

PM> Install-Package TacitusLogger.Destinations.Trace

Examples

Adding trace destination with default parameters

Using builders:

ILogger logger = LoggerBuilder.Logger().ForAllLogs()
                                       .Trace().Add()
                                       .BuildLogger();

Or directly:

TraceDestination traceDestination = new TraceDestination();
Logger logger = new Logger();
logger.AddLogDestinations(traceDestination);

Trace destination with simple template log serializer

Using builders:

string template = "[$LogDate]-[$LogType]-[$Description]-[From: $Context]-[Src: $Source]-[Id: $LogId]";
ILogger logger = LoggerBuilder.Logger()
                              .ForAllLogs()
                              .Trace().WithSimpleTemplateLogText(template)
                                      .Add()
                              .BuildLogger();

Or directly:

string template = "[$LogDate]-[$LogType]-[$Description]-[From: $Context]-[Src: $Source]-[Id: $LogId]";
TraceDestination traceDestination = new TraceDestination(template);
Logger logger = new Logger();
logger.NewLogGroup(x => true).AddDestinations(traceDestination);

Trace destination with custom log serializer

Using builders:

ILogSerializer customLogSerializer = new Mock<ILogSerializer>().Object;

ILogger logger = LoggerBuilder.Logger()
                             .ForAllLogs()
                             .Trace().WithCustomLogSerializer(customLogSerializer)
                                     .Add()
                             .BuildLogger();

Or directly:

ILogSerializer customLogSerializer = new Mock<ILogSerializer>().Object;
TraceDestination traceDestination = new TraceDestination(customLogSerializer);
Logger logger = new Logger();
logger.NewLogGroup(x => true).AddDestinations(traceDestination);

License

APACHE LICENSE 2.0

See also

TacitusLogger:

Destinations:

Dependency injection:

  • TacitusLogger.DI.Ninject - Extension for Ninject dependency injection container that helps to configure and add TacitusLogger as a singleton.
  • TacitusLogger.DI.Autofac - Extension for Autofac dependency injection container that helps to configure and add TacitusLogger as a singleton.
  • TacitusLogger.DI.MicrosoftDI - Extension for Microsoft dependency injection container that helps to configure and add TacitusLogger as a singleton.

Log contributors:

About

Extension destination for TacitusLogger that sends logs to System.Diagnostics.Trace listeners.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages