Simplify.Log
2.3.1
dotnet add package Simplify.Log --version 2.3.1
NuGet\Install-Package Simplify.Log -Version 2.3.1
<PackageReference Include="Simplify.Log" Version="2.3.1" />
<PackageVersion Include="Simplify.Log" Version="2.3.1" />
<PackageReference Include="Simplify.Log" />
paket add Simplify.Log --version 2.3.1
#r "nuget: Simplify.Log, 2.3.1"
#:package Simplify.Log@2.3.1
#addin nuget:?package=Simplify.Log&version=2.3.1
#tool nuget:?package=Simplify.Log&version=2.3.1
Simplify.Log Documentation
Provides ILogger interface and Logger class for file-based logging.
With Logger, you can write messages to a text log, including simple strings or exception data with full stack trace, line numbers, and inner exceptions stack traces.
Available at NuGet as binary package
Simple string log message example
[01.03.2014 18:24:11:330] Main : Hello world!!!
Exception log message example
[26.02.2014 13:39:00:023] NHibernate.Exceptions.GenericADOException : could not execute query
[ select flightexcl0_.ID as ID5462_, flightexcl0_.FlightNumber as FlightNu2_5462_ from FlightsExcludeList flightexcl0_ ]
[SQL: select flightexcl0_.ID as ID5462_, flightexcl0_.FlightNumber as FlightNu2_5462_ from FlightsExcludeList flightexcl0_]
at NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters)
at NHibernate.Loader.Loader.ListIgnoreQueryCache(ISessionImplementor session, QueryParameters queryParameters)
at NHibernate.Loader.Loader.List(ISessionImplementor session, QueryParameters queryParameters, ISet`1 querySpaces, IType[] resultTypes)
at NHibernate.Hql.Ast.ANTLR.Loader.QueryLoader.List(ISessionImplementor session, QueryParameters queryParameters)
at NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.List(ISessionImplementor session, QueryParameters queryParameters)
at NHibernate.Engine.Query.HQLQueryPlan.PerformList(QueryParameters queryParameters, ISessionImplementor session, IList results)
at NHibernate.Impl.SessionImpl.List(IQueryExpression queryExpression, QueryParameters queryParameters, IList results)
at NHibernate.Impl.AbstractSessionImpl.List(IQueryExpression queryExpression, QueryParameters parameters)
at NHibernate.Impl.ExpressionQueryImpl.List()
at NHibernate.Linq.DefaultQueryProvider.ExecuteQuery(NhLinqExpression nhLinqExpression, IQuery query, NhLinqExpression nhQuery)
at NHibernate.Linq.DefaultQueryProvider.Execute(Expression expression)
at NHibernate.Linq.DefaultQueryProvider.Execute[TResult](Expression expression)
at Remotion.Linq.QueryableBase`1.GetEnumerator()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at FluentNHibernate.Extender.DbConnection.GetList[T](Expression`1 filterFunc)
at Processing.Processing.Processor..ctor(IDbConnection dbConnection, IList`1 officesForProcessing) in c:\CCNet\WorkingDirectory\Processing\src\Processing\Processing\Processor.cs:line 81
at Processing.Service.OnWork(Object state) in c:\CCNet\WorkingDirectory\SsrProcessing\src\SsrProcessing\Service.cs:line 52
[Inner Exception] Oracle.ManagedDataAccess.Client.OracleException : Connection request timed out
at OracleInternal.ConnectionPool.PoolManager`3.CreateNewPR(Int32 reqCount, Boolean bForPoolPopulation, ConnectionString csWithDiffOrNewPwd, String instanceName)
at OracleInternal.ConnectionPool.PoolManager`3.Get(ConnectionString csWithDiffOrNewPwd, Boolean bGetForApp, String affinityInstanceName, Boolean bForceMatch)
at OracleInternal.ConnectionPool.OraclePoolManager.Get(ConnectionString csWithNewPassword, Boolean bGetForApp, String affinityInstanceName, Boolean bForceMatch)
at OracleInternal.ConnectionPool.OracleConnectionDispenser`3.Get(ConnectionString cs, PM conPM, ConnectionString pmCS, SecureString securedPassword, SecureString securedProxyPassword)
at Oracle.ManagedDataAccess.Client.OracleConnection.Open()
at NHibernate.Connection.DriverConnectionProvider.GetConnection()
at NHibernate.AdoNet.ConnectionManager.GetConnection()
at NHibernate.AdoNet.AbstractBatcher.Prepare(IDbCommand cmd)
at NHibernate.AdoNet.AbstractBatcher.ExecuteReader(IDbCommand cmd)
at NHibernate.Loader.Loader.GetResultSet(IDbCommand st, Boolean autoDiscoverTypes, Boolean callable, RowSelection selection, ISessionImplementor session)
at NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies)
at NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies)
at NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters)
General usage
Logger (implementing ILogger, namespace Simplify.Log) is instantiated directly, optionally with configuration.
- When created with default parameters, data is written to a
Logs.logfile using a relative path (calling assembly location). If a log file size exceeds the limit (5000 KB ≈ 5 MB by default), it will be cleaned.
Creating a logger with default settings
using Simplify.Log;
ILogger logger = new Logger();
Writing a simple string to a log
logger.Write("Hello world!!!");
Writing an exception to a log
try
{
...
}
catch (Exception e)
{
logger.Write(e);
}
WriteWeb(Exception e) writes the same data but returns it formatted with HTML line breaks (<br />). The Generate / GenerateWeb methods build the same formatted message text without writing it to the file.
Custom usage
Initialization with parameters
The parameterized constructor lets you override the defaults directly:
// public Logger(int maxFileSize = 5000, string fileName = "Logs.log",
// LoggerPathType pathType = LoggerPathType.Relative, bool showTraceOutput = false)
var logger = new Logger(
maxFileSize: 5000,
fileName: @"C:\Logs\MyApp.log",
pathType: LoggerPathType.FullPath,
showTraceOutput: true);
LoggerPathType is an enum with two values: Relative (default, relative to the calling assembly location) and FullPath (the file name is treated as an absolute path).
Initialization from configuration
Logger can be created from an IConfiguration. By default it reads the Logger section; a different section name can be passed as the second argument:
using Microsoft.Extensions.Configuration;
using Simplify.Log;
var config = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.Build();
// Reads the "Logger" section by default
var logger = new Logger(config);
// Or specify a custom section name
var customLogger = new Logger(config, "MyLoggerSettings");
{
"Logger": {
// Override log file name and use full path type
"FileName": "C:\\Logs\\MyApp.log",
"PathType": "FullPath",
// Maximum file size in KB
"MaxFileSize": "5000",
// Sends a copy of data written to the log file to trace (Visual Studio output window)
"ShowTraceOutput": "true"
}
}
All configuration keys (FileName, MaxFileSize, PathType, ShowTraceOutput) are optional; omitted keys fall back to the defaults above.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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 is compatible. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.9)
- System.IO.Abstractions (>= 22.1.1)
-
.NETStandard 2.1
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.9)
- System.IO.Abstractions (>= 22.1.1)
-
net9.0
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.9)
- System.IO.Abstractions (>= 22.1.1)
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.3.1 | 0 | 6/25/2026 |
| 2.3.0 | 579 | 6/15/2025 |
| 2.2.1 | 695 | 8/26/2023 |
| 2.1.0 | 575 | 11/30/2022 |
| 2.0.3 | 720 | 5/2/2022 |
| 2.0.2 | 588 | 1/3/2022 |
| 2.0.1 | 568 | 12/18/2021 |
| 2.0.0 | 595 | 10/26/2021 |
| 1.6.2 | 782 | 2/2/2021 |
| 1.6.1 | 769 | 12/10/2020 |
| 1.6.0 | 827 | 7/7/2020 |
| 1.4.3 | 932 | 9/28/2019 |
| 1.4.2 | 921 | 6/23/2019 |
| 1.4.1 | 972 | 4/16/2019 |
| 1.4.0 | 1,068 | 1/4/2019 |
| 1.3.1 | 1,247 | 10/1/2018 |
| 1.3.0 | 1,645 | 6/19/2018 |
| 1.2.0 | 1,710 | 4/15/2018 |
| 1.1.1 | 1,518 | 8/24/2017 |
| 1.1.0 | 1,621 | 8/18/2016 |