{"id":19720828,"url":"https://github.com/hexaengine/hexa.net.logging","last_synced_at":"2025-04-29T21:31:01.745Z","repository":{"id":250438298,"uuid":"834492033","full_name":"HexaEngine/Hexa.NET.Logging","owner":"HexaEngine","description":"Hexa.NET.Logging is a small, efficient logging framework for .NET applications.","archived":false,"fork":false,"pushed_at":"2024-07-27T12:43:29.000Z","size":20,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-01T16:39:31.384Z","etag":null,"topics":["csharp","lightweight","logging","logging-framework","logging-library"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HexaEngine.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-27T12:36:23.000Z","updated_at":"2024-08-05T03:33:38.000Z","dependencies_parsed_at":"2024-07-27T13:10:41.579Z","dependency_job_id":null,"html_url":"https://github.com/HexaEngine/Hexa.NET.Logging","commit_stats":null,"previous_names":["hexaengine/hexa.net.logging"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HexaEngine%2FHexa.NET.Logging","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HexaEngine%2FHexa.NET.Logging/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HexaEngine%2FHexa.NET.Logging/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HexaEngine%2FHexa.NET.Logging/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HexaEngine","download_url":"https://codeload.github.com/HexaEngine/Hexa.NET.Logging/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251585771,"owners_count":21613277,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csharp","lightweight","logging","logging-framework","logging-library"],"created_at":"2024-11-11T23:12:35.570Z","updated_at":"2025-04-29T21:30:58.861Z","avatar_url":"https://github.com/HexaEngine.png","language":"C#","readme":"# Hexa.NET.Logging\n\n## Overview\n\nHexa.NET.Logging is a small, efficient logging framework for .NET applications. It provides a simple API for logging messages at various levels (e.g., error, warning, information). This framework is designed to be lightweight and easy to integrate into your existing .NET applications.\n\n## Features\n\n- Lightweight and efficient logging.\n- Easy-to-use API.\n- Support for multiple logging levels.\n- Ability to cache loggers for improved performance.\n- Exception logging support.\n- Conditional logging support.\n- Async logging support.\n\n## Installation\n\nTo install Hexa.NET.Logging, add the following package to your project:\n\n```bash\ndotnet add package Hexa.NET.Logging\n```\n\nUsage\n\nHere is a basic example of how to use Hexa.NET.Logging in your application:\n\n1. Getting a Logger:\n```csharp\nusing Hexa.NET.Logging;\n\n// Add a log writer. (LogFileWriter is a build-in log writer.)\nvar logWriter = new LogFileWriter(\"logs\");\nLoggerFactory.AddGlobalWriter(logWriter);\n\n// Retrieve a logger for a specific category\nvar logger = LoggerFactory.GetLogger(nameof(MyClass));\n\n// Store the logger in a static field/property for better performance\nprivate static readonly ILogger _logger = LoggerFactory.GetLogger(nameof(MyClass));\n```\n\n2. Logging Messages:\n```csharp\n// Log an error message\n_logger.Error(\"Failed to create input layout, signature was null.\");\n\n// Log a warning message\n_logger.Warning(\"This is a warning message.\");\n\n// Log an informational message\n_logger.Info(\"This is an informational message.\");\n```\n\n3. Logging Exceptions:\n```csharp\ntry\n{\n    // Your code here\n}\ncatch (Exception ex)\n{\n    _logger.Log(ex); // Log the exception\n}\n```\n\n4. Conditional Logging:\n```csharp\n// Log a message only if a condition is met\n_logger.WarnIf(foo == bar, \"This is a warning message.\");\n```\n\n5. Example in a Class:\n```csharp\nusing Hexa.NET.Logging;\n\npublic class MyClass\n{\n    private static readonly ILogger _logger = LoggerFactory.GetLogger(nameof(MyClass));\n\n    public void SomeMethod()\n    {\n        _logger.Info(\"This is an informational message.\");\n        try\n        {\n            // Your code here\n        }\n        catch (Exception ex)\n        {\n            _logger.Log(ex); // Log the exception\n        }\n    }\n}\n```\n\n## Logging Levels\n\nHexa.NET.Logging supports the following logging levels:\n\n- Critical: Use for logging critical messages that indicate a critical failure in the application.\n- Error: Use for logging error messages that indicate a failure in the application.\n- Warning: Use for logging warning messages that indicate a potential issue or important information.\n- Info: Use for logging informational messages that highlight the progress of the application.\n- Debug: Use for logging debug messages that provide detailed information for debugging purposes.\n- Trace: Use for logging trace messages that provide detailed information for tracing purposes.\n\n## Best Practices\n\n- **Cache Loggers:** Store the ILogger instances in static fields or properties to avoid retrieving the logger multiple times, which can improve performance.\n- **Use Appropriate Logging Levels:** Use the correct logging level to ensure that the log output is meaningful and easy to understand.\n- **Log Exceptions:** Use the Log(Exception ex) method to log exceptions and capture stack trace information.\n- **Conditional Logging:** Use conditional logging methods to log messages based on specific conditions.\n\n## Contributing\n\nContributions are welcome! Please fork the repository and submit a pull request with your changes. Ensure that your code follows the project's coding standards and includes appropriate tests.\n\n## License\n\nHexa.NET.Logging is licensed under the MIT License. See the [LICENSE](https://github.com/HexaEngine/Hexa.NET.Logging/blob/master/LICENSE.txt) file for more details.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhexaengine%2Fhexa.net.logging","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhexaengine%2Fhexa.net.logging","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhexaengine%2Fhexa.net.logging/lists"}