CustomLog 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package CustomLog --version 1.0.0
                    
NuGet\Install-Package CustomLog -Version 1.0.0
                    
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="CustomLog" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CustomLog" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="CustomLog" />
                    
Project file
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 CustomLog --version 1.0.0
                    
#r "nuget: CustomLog, 1.0.0"
                    
#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 CustomLog@1.0.0
                    
#: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=CustomLog&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=CustomLog&version=1.0.0
                    
Install as a Cake Tool

CustomLog

CustomLogis a simple and lightweight logging library for .NET applications. It allows you to log messages, warnings, and errors to a specified log file, ensuring that the log file is created if it does not already exist.

Features

  • Log messages with timestamps.
  • Log messages categorized as Info, Warning, and Error.
  • Automatically creates the log file if it does not exist.

Installation

To use CustomLog, you can either clone the repository or add the class directly to your project.

Prerequisites

  • .NET Framework or .NET Core
  • Basic knowledge of C# and .NET development

Usage

1. Create an Instance of SLogger

To use the SLogger, create an instance of the class by providing the path to the log file.

using myLogger;

class Program
{
    static void Main(string[] args)
    {
        var logger = new SLogger("log.txt");
                logger.EnsureLogFileExists("log.txt"); // Ensure the log file exists
        // Log messages
        logger.LogInfo("Application started.");
        logger.LogWarning("This is a warning message.");
        logger.LogError("An error occurred.");
        
        Console.WriteLine("Logs written to log.txt");
    }
}

2. Logging Messages
You can log messages using the following methods:

Log: Logs a general message.
LogInfo: Logs an informational message.
LogWarning: Logs a warning message.
LogError: Logs an error message.
Example
csharp

Verify

Open In Editor
Edit
Copy code
logger.Log("This is a general log message.");
logger.LogInfo("This is an informational message.");
logger.LogWarning("This is a warning message.");
logger.LogError("This is an error message.");
File Structure
The log messages will be written to the specified log file in the following format:


Verify

Open In Editor
Edit
Copy code
[Timestamp]: [Log Message]
Example Log Output

Verify

2023-10-01 12:00:00: INFO: Application started.
2023-10-01 12:01:00: WARNING: This is a warning message.
2023-10-01 12:02:00: ERROR: An error occurred.
Conclusion
SLogger is a straightforward solution for logging in .NET applications. It provides essential logging functionalities while ensuring that the log file is always available for recording messages. For any further questions or contributions, feel free to reach out!
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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.
  • net6.0

    • No dependencies.

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
2.0.0 151 10/23/2025
1.1.0 137 11/14/2024
1.0.0 111 11/14/2024