NTrigoLogger 1.0.2
The owner has unlisted this package.
This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package NTrigoLogger --version 1.0.2
NuGet\Install-Package NTrigoLogger -Version 1.0.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NTrigoLogger" Version="1.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NTrigoLogger" Version="1.0.2" />
<PackageReference Include="NTrigoLogger" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add NTrigoLogger --version 1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: NTrigoLogger, 1.0.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package NTrigoLogger@1.0.2
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=NTrigoLogger&version=1.0.2
#tool nuget:?package=NTrigoLogger&version=1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
NTrigoLogger
Logger centralizado e sistema de health check para aplicações .NET 8.0+. Captura automática de logs, exceções e métricas de saúde com envio para API centralizada.
Instalação
dotnet add package NTrigoLogger
Configuração Rápida
1. Configuração Mínima (Console/Worker Service)
using NTrigoLogger;
// Configuração simples
UseTrigoLogger.Configure(
apiKey: "sua-api-key-aqui",
serviceName: "MeuServico",
endpointUrl: "https://api.trigo.com",
isProduction: false
);
// Seu código aqui...
// Logs e exceções serão capturados automaticamente
// Ao finalizar a aplicação
UseTrigoLogger.Shutdown();
2. Configuração em ASP.NET Core
// Program.cs
using NTrigoLogger;
var builder = WebApplication.CreateBuilder(args);
// Adiciona NTrigoLogger aos serviços
builder.Services.AddTrigoLogger(options =>
{
options.ApiKey = "sua-api-key-aqui";
options.ServiceName = "MinhaAPI";
options.EndpointUrl = "https://api.trigo.com";
options.IsProduction = builder.Environment.IsProduction();
options.HealthCheckInterval = TimeSpan.FromMinutes(1);
options.EnableAutomaticExceptionCapture = true;
options.EnableHealthCheck = true;
options.BufferLogs = true;
options.BufferSize = 100;
});
builder.Services.AddControllers();
var app = builder.Build();
// Adiciona o middleware do NTrigoLogger
app.UseTrigoLoggerMiddleware();
app.MapControllers();
app.Run();
Uso Básico
Logging Manual
using NTrigoLogger;
// Log de informação
await Logger.LogInfo("Aplicação iniciada com sucesso");
// Log de aviso
await Logger.LogWarning("Cache expirado, recarregando dados");
// Log de erro
try
{
// código que pode gerar exceção
}
catch (Exception ex)
{
await Logger.LogError(ex, "Erro ao processar pedido");
}
// Log com dados adicionais
await Logger.LogInfo(
"Pedido processado",
source: "OrderService",
additionalData: new
{
orderId = 12345,
customerId = 67890,
total = 150.50
},
userName: "user@example.com"
);
// Log fatal
await Logger.LogFatal("Erro crítico no sistema", stackTrace: Environment.StackTrace);
Health Checks Personalizados
using NTrigoLogger;
// Registrar health check de banco de dados
HealthCheck.RegisterDatabaseCheck(
connectionString: "Server=localhost;Database=MyDB;...",
name: "SQLServer"
);
// Registrar health check de serviço HTTP
HealthCheck.RegisterHttpCheck(
url: "https://api.externa.com/health",
name: "APIExterna"
);
// Registrar health check de rede
HealthCheck.RegisterPingCheck(
hostName: "google.com",
name: "InternetConnectivity"
);
// Health check customizado
HealthCheck.RegisterCheck("CustomService", async () =>
{
try
{
// Sua lógica de verificação aqui
var isHealthy = await CheckMyService();
return new HealthCheck.HealthCheckResult
{
Status = isHealthy ? HealthStatus.Healthy : HealthStatus.Unhealthy,
Message = isHealthy ? "Serviço OK" : "Serviço com problemas",
ResponseTimeMs = 50,
Details = new { checkedAt = DateTime.UtcNow }
};
}
catch (Exception ex)
{
return new HealthCheck.HealthCheckResult
{
Status = HealthStatus.Unhealthy,
Message = $"Erro: {ex.Message}",
ResponseTimeMs = 0
};
}
});
// Executar health checks manualmente
var results = await HealthCheck.RunHealthChecksManually();
foreach (var result in results)
{
Console.WriteLine($"{result.Key}: {result.Value.Status} - {result.Value.Message}");
}
Configuração Avançada
builder.Services.AddTrigoLogger(options =>
{
// Configurações obrigatórias
options.ApiKey = "sua-api-key";
options.ServiceName = "MeuServico";
// Configurações opcionais
options.EndpointUrl = "https://localhost:7189"; // Default
options.IsProduction = true; // Default: true
options.HealthCheckInterval = TimeSpan.FromMinutes(5); // Default: 1 minuto
// Níveis de log a capturar
options.LogLevels = new List<LogLevel>
{
LogLevel.INFO,
LogLevel.WARNING,
LogLevel.ERROR,
LogLevel.FATAL
};
// Captura automática
options.EnableAutomaticExceptionCapture = true; // Default: true
options.EnableHealthCheck = true; // Default: true
options.EnableDetailedErrors = true; // Default: true
// Configurações de retry
options.MaxRetryAttempts = 3; // Default: 3
options.RetryDelay = TimeSpan.FromSeconds(2); // Default: 2 segundos
// Buffer de logs
options.BufferLogs = true; // Default: true
options.BufferSize = 100; // Default: 100
options.BufferFlushInterval = TimeSpan.FromSeconds(10); // Default: 10 segundos
});
Recursos Principais
🚀 Captura Automática
- Exceções não tratadas: Todas as exceções são automaticamente capturadas e enviadas
- Requisições HTTP: Com o middleware, todas as requisições são logadas automaticamente
- Métricas de sistema: CPU, memória, threads são monitorados automaticamente
📊 Informações Capturadas
- Logs: Nível, mensagem, fonte, stack trace, dados adicionais
- Contexto: Nome da máquina, ID do processo, thread, usuário
- Requisições: Método, path, headers, body, tempo de resposta
- Sistema: CPU, memória, uptime, sistema operacional
🔄 Health Checks
- ApiService: Verificação automática das rotas da API
- System: Monitoramento de CPU e memória
- Custom: Adicione seus próprios health checks
⚡ Performance
- Buffer de logs: Agrupa logs para envio em lote
- Retry automático: Reenvio em caso de falha
- Assíncrono: Não bloqueia a aplicação principal
Requisitos
- .NET 8.0 ou superior
- ASP.NET Core 8.0 (para usar o middleware)
Suporte
Para reportar problemas ou sugestões, abra uma issue no GitHub.
Licença
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- System.Text.Json (>= 8.0.5)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|