All Projects → cosmos-loops → cosmos-logging

cosmos-loops / cosmos-logging

Licence: Apache-2.0 license
Logging component for .NET Core with nice APIs for developers to use.

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to cosmos-logging

Terse Logback
Structured Logging, Tracing, and Observability with Logback
Stars: ✭ 146 (+421.43%)
Mutual labels:  structured-logging
cosmos-snapshots
Automatic snapshots of the blockchain state
Stars: ✭ 71 (+153.57%)
Mutual labels:  cosmos
cosmospy
Python tools for Cosmos wallet management and offline transaction signing
Stars: ✭ 57 (+103.57%)
Mutual labels:  cosmos
Zap
Blazing fast, structured, leveled logging in Go.
Stars: ✭ 14,384 (+51271.43%)
Mutual labels:  structured-logging
Timber Elixir
🌲 Great Elixir logging made easy
Stars: ✭ 226 (+707.14%)
Mutual labels:  structured-logging
resharper-structured-logging
An extension for ReSharper and Rider that highlights structured logging templates and contains some useful analyzers
Stars: ✭ 117 (+317.86%)
Mutual labels:  structured-logging
Documentation
Stars: ✭ 133 (+375%)
Mutual labels:  structured-logging
Prism-OS
An operating system created in c#, Made possible by the cosmos community!
Stars: ✭ 45 (+60.71%)
Mutual labels:  cosmos
CosmicClone
Cosmic Clone is a utility that can backup\clone\restore a azure Cosmos database Collection. It can also anonymize cosmos documents and helps hide personally identifiable data.
Stars: ✭ 113 (+303.57%)
Mutual labels:  cosmos
kafka-connect-cosmosdb
Kafka Connect connectors for Azure Cosmos DB
Stars: ✭ 28 (+0%)
Mutual labels:  cosmos
Ougai
A Ruby structured logging is capable of handling a message, custom data or an exception easily and generates JSON or human readable logs.
Stars: ✭ 187 (+567.86%)
Mutual labels:  structured-logging
Slog
Minimal structured logging library for Go
Stars: ✭ 210 (+650%)
Mutual labels:  structured-logging
testnet deploy
Deployment scripts and monitoring configuration for a Cosmos Validator setup
Stars: ✭ 19 (-32.14%)
Mutual labels:  cosmos
Timber Ruby
🌲 Great Ruby logging made easy.
Stars: ✭ 154 (+450%)
Mutual labels:  structured-logging
sommelier
Sommelier Chain
Stars: ✭ 64 (+128.57%)
Mutual labels:  cosmos
Structured Log
A JavaScript implementation of Serilog's hybrid text/structured logging
Stars: ✭ 133 (+375%)
Mutual labels:  structured-logging
terra-rust
Rust <-> Terrad API via LCD service
Stars: ✭ 31 (+10.71%)
Mutual labels:  cosmos
bdjuno
BDJuno is the official Juno implementation for BigDipper, the open-source block explorer for Cosmos
Stars: ✭ 34 (+21.43%)
Mutual labels:  cosmos
Beef
Business Entity Execution Framework
Stars: ✭ 95 (+239.29%)
Mutual labels:  cosmos
beautiful logger
Yet another logger API in Java with beautiful features
Stars: ✭ 60 (+114.29%)
Mutual labels:  logger-interface

COSMOSLOOPS/Cosmos.Logging

Logging component for .NET Core with nice APIs for developers to use. Cosmos.Logging is support for structured logging message in several kinds of .NET applications.

This repository belongs to Cosmosloops Labs..

Nuget Packages

Usage

Install the package

Install-Package Cosmos.Logging

Install the specific sink packages, renderer packages or extension packages that you need.

Work in console

Install console package first:

Install-Package Cosmos.Logging.RunsOn.Console

then: (in this case we integrated NLog sink)

static void Main(string[] args)
{
    //load configuration info
    var root = new ConfigurationBuilder()
        .SetBasePath(Directory.GetCurrentDirectory())
        .AddJsonFile("appsettings.json", true, true)
        .Build();

    //initialize logger
    LOGGER.Initialize(root).RunsOnConsole().AddNLog().AddSampleLog().AllDone();

    //submit log manually
    var logger1 = LOGGER.GetLogger<Program>(mode: LogEventSendMode.Manually);
    logger1.LogWarning("hello, {$Date} {$MachineName}");
    logger1.SubmitLogger();

    //or submit log automatically
    var logger2 = LOGGER.GetLogger<Program>();
    logger2.LogWarning("world");

    //get a future logger
    var logger3 = LOGGER.GetLogger<Program>().ToFuture();

    //or convert a normal to future logger
    var logger4 = logger2.ToFuture();

    //or get a future logger directly
    var logger5 = FUTURE.GetFutureLogger<Program>();

    //and how to use future logger via a nice fluent api
    logger5.SetLevel(LogEventLevel.Warning)
        .SetMessage("future log===> Nice {@L}")
        .SetTags("Alex", "Lewis")
        .SetParameter(new {L = "KK2"})
        .SetException(new ArgumentNullException(nameof(args)))
        .Submit();

    //or you can use a optional-parameters-style api in your Application-Framework
    logger5.UseFields(
        Fields.Level(LogEventLevel.Warning),
        Fields.Message("future log===> Nice {@L}"),
        Fields.Tags("Alex", "Lewis"),
        Fields.Args(new {L = "KK3"}),
        Fields.Exception(new ArgumentNullException(nameof(args)))).Submit();
}

Work with Microsoft ASP.NET Core Mvc

Install aspnetcore package first:

Install-Package Cosmos.Logging.RunsOn.AspNetCore

then write code in Startup.cs: (in this case, we integrated SqlSugar ORM)

public void ConfigureServices(IServiceCollection services)
{
    //...

    services.AddCosmosLogging(Configuration, config => config
            .ToGlobal(o => o.UseMinimumLevel(LogEventLevel.Information))
            .AddDatabaseIntegration(o => o.UseSqlSugar(sugar => sugar.UseAlias("Everything", LogEventLevel.Verbose)))
            .AddSampleLog());

    //...
}

finally, just to writing your code:

public class HomeController : Controller
{
    private readonly ILoggingServiceProvider _loggingProvider;

    public HomeController(ILoggingServiceProvider loggingProvider) {
        _loggingProvider = loggingProvider ?? throw new ArgumentNullException(nameof(loggingProvider));
    }

    // GET
    public IActionResult Index() {
        var log = _loggingProvider.GetLogger<HomeController>();
        log.LogInformation("Nice @ {$Date}");
        return Content("Nice");
    }
}

Work with Microsoft ASP.NET Mvc

Install aspnet package first:

Install-Package Cosmos.Logging.RunsOn.AspNet

or (if you use Autofac as your default IoC container)

Install-Package Cosmos.Logging.RunsOn.AspNet.WithAutofac

then

//in Global.asax.cs
public class Global : HttpApplication
{
    //...
    this.RegisterCosmosLogging(s => s.ToGlobal(c => c.UseMinimumLevel(LogEventLevel.Verbose)).AddSampleLog());
}

Thanks

People or projects that have made a great contribution to this project:

  • The next one must be you

Organizations and projects

  • The next one must be yours

License

Member project of Cosmosloops Labs..

Apache License 2.0

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].