Skip to content

Latest commit

 

History

84 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Atata.NLog

NuGet GitHub release Build status Atata Templates
Slack Atata docs X

Atata.NLog is a .NET library that adds NLog logging to Atata.

The package targets .NET 8.0 and .NET Framework 4.6.2.

Installation

Install the package via .NET CLI:

dotnet add package Atata.NLog

Or using Package Manager:

Install-Package Atata.NLog

Dependencies

Usage

In order to add NLog logging to Atata, call AddNLog (to use NLog.config) or AddNLogFile (no config file needed) extension method on the "base" LogConsumersBuilder instance in GlobalFixture.

public sealed class GlobalFixture : AtataGlobalFixture
{
    protected override void ConfigureAtataContextBaseConfiguration(AtataContextBuilder builder)
    {
        builder.LogConsumers.AddNLogFile();
    }
}

Also you can configure some of the settings:

builder.LogConsumers.AddNLogFile(x => x
    .WithMinLevel(LogLevel.Info)
    .WithFileNameTemplate("Info.log"));

API

NLogConsumersBuilderExtensions

Provides NLog extension methods for LogConsumersBuilder.

public static class NLogConsumersBuilderExtensions
{
    // Adds the NLogConsumer instance that uses NLog.Logger class for logging.
    public static AtataContextBuilder AddNLog(
        this LogConsumersBuilder builder,
        Action<LogConsumerBuilder<NLogConsumer>>? configure = null);

    // Adds the NLogFileConsumer instance that uses NLog.Logger class for logging into file.
    public static AtataContextBuilder AddNLogFile(
        this LogConsumersBuilder builder,
        Action<LogConsumerBuilder<NLogFileConsumer>>? configure = null);
}

NLogConsumerBuilderExtensions

Provides NLog extension methods for LogConsumerBuilder<TLogConsumer>.

public static class NLogConsumerBuilderExtensions
{
    // Sets the file name template of the log file.
    // The default value is "Atata.log".
    public static LogConsumerBuilder<NLogFileConsumer> WithFileNameTemplate(
        this LogConsumerBuilder<NLogFileConsumer> builder,
        string fileNameTemplate);

    // Specifies the layout of log event.
    // The default value is @"${event-property:time-elapsed:format=hh\\\:mm\\\:ss\\.fff} ${event-property:execution-unit-id} ${uppercase:${level}:padding=5} ${event-property:log-nesting-text}${when:when='${event-property:log-source}'!='':inner={${event-property:log-source}\} }${when:when='${event-property:log-category}'!='':inner=[${event-property:log-category}] }${when:when='${message}'!='':inner=${message}${onexception:inner= }${exception:format=ToString:flattenException=false}:else=${exception:format=ToString:flattenException=false}".
    // If you want to replace "time elapsed" column in layout with "timestamp", you can replace the value
    // "{event-property:time-elapsed:format=hh\\\:mm\\\:ss\\.fff}" with
    // "{date:format=yyyy-MM-dd HH\:mm\:ss.fff}".
    public static LogConsumerBuilder<NLogFileConsumer> WithLayout(
        this LogConsumerBuilder<NLogFileConsumer> builder,
        string layout);

    // Specifies to use separate log files for log sources.
    // The main log file will be "Atata.log".
    // Source log file will be "{source}.log", e.g., "Browser.log", "App.log".
    // Sets "${{event-property:log-source:whenEmpty=Atata}}.log" to NLogFileConsumer.FileNameTemplate.
    // Sets @"${event-property:time-elapsed:format=hh\\\:mm\\\:ss\\.fff} ${event-property:execution-unit-id} ${uppercase:${level}:padding=5} ${event-property:log-nesting-text}${when:when='${event-property:log-category}'!='':inner=[${event-property:log-category}] }${when:when='${message}'!='':inner=${message}${onexception:inner= }${exception:format=ToString:flattenException=false}:else=${exception:format=ToString:flattenException=false}" to NLogFileConsumer.Layout.
    public static LogConsumerBuilder<NLogFileConsumer> WithSeparateSourceLogFiles(
        this LogConsumerBuilder<NLogFileConsumer> builder);
}

Community

Feedback

Any feedback, issues and feature requests are welcome.

If you faced an issue please report it to Atata.NLog Issues, ask a question on Stack Overflow using atata tag or use another Atata Contact way.

Contact author

Contact me, Yevhenii Shunevych, if you need help with test automation using the Atata Framework. You can hire me for test automation development or consulting if you are looking for a high-quality, maintainable automation solution for your project.

Sponsorship

Many thanks to the sponsors that regularly support the development of Atata Framework through donations:

If Atata Framework is useful to you or your company, consider supporting the framework development with a donation.

Contributing

Check out Contributing Guidelines for details.

SemVer

Atata Framework tries to follow Semantic Versioning 2.0 when possible. Sometimes Selenium.WebDriver dependency package can contain breaking changes in minor version releases, so those changes can break Atata as well. But Atata manages its sources according to SemVer. Thus backward compatibility is mostly followed and updates within the same major version (e.g. from 2.1 to 2.2) should not require code changes.

License

Atata is an open source software, licensed under the Apache License 2.0. See LICENSE for details.

About

.NET library that adds NLog logging to Atata

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Sponsor this project

Contributors

Languages