Releases: Abc-Arbitrage/ZeroLog
Releases · Abc-Arbitrage/ZeroLog
v2.2.0
New features
- Added a
LogManager.Flush
method, which can be useful in benchmarks - Added custom
TimeProvider
support in the configuration (#62, requires .NET 8) - Added
%localDate
and%localTime
placeholders (#64)
Fixes
- Fixed
LogManager.RegisterAllEnumsFrom
to be safe to use with assemblies containing invalid types - Fixed enum support on .NET 6 under Linux
v2.1.1
- Fixed a race condition on shutdown where the last messages could be skipped
v2.1.0
Formatting
- Formattable prefix placeholders with the
%{type:format}
syntax, e.g.%{date:yyyy-MM-dd HH:mm:ss}
- An integer format can be used on string placeholders to specify a minimum field length, e.g.
%{logger:40}
%{level:pad}
can be used to make log levels a constant length (alias for%{level:5}
)
- An integer format can be used on string placeholders to specify a minimum field length, e.g.
- New prefix placeholders:
%newline
inserts a system-dependent newline%{column:N}
inserts padding until the column indexN
is reached%loggerCompact
inserts the logger name with a shortened namespace, e.g.Foo.Bar.Baz
=>FB.Baz
- New Roslyn analyzer which validates constant prefix patterns at build-time
- Added
TextWriterAppender
(useTextWriterAppender(Console.Out)
in unit tests) - New APIs in
LoggedKeyValue
:ValueType
,TryGetValue<T>
Unit testing
- Added
ZeroLogConfiguration CreateTestConfiguration()
with suitable defaults for unit testing - Support for a synchronous appending strategy (on the current thread) for use in unit tests (
AppendingStrategy
setting) - Added
LoggedMessage.Clone()
to capture logged messages - Snapshot testing with Verify.ZeroLog
Configuration
- Added new convenience APIs for configuration:
ZeroLogConfiguration.SetLogLevel
- New
LoggerConfiguration
constructor overloads - New initializer syntax for adding
Loggers
to the collection:Loggers = { { NameA, LevelA }, { NameB, LevelB } }
- Made the
UseBackgroundThread
setting obsolete: the worker thread is now always a background thread - Added a
LogManager.Configuration
property
Various
- Added a pool exhaustion strategy which is allowed to allocate
- Added support for
DateTimeOffset
- Don't flood "Pool exhausted" messages
- Various optimizations and bug fixes
v2.0.1
v2.0.0
Rewrite for .NET 6
ZeroLog has been entirely rewritten to take advantage of new APIs in .NET 6 and new features of C# 10. Therefore, v2 only works on .NET 6 and above. A .NET Standard 2.0 target is provided to enable logging from libraries, but the main project needs to target .NET 6.
The surface API has been redesigned, but migration from v1 should still be straightforward (even though repetitive work is required).
See the readme file for more detailed information, and #44 for implementation notes.
Major changes
InfoFormat
(and similar) methods have been removed, they are replaced by the new interpolated string handlers feature of C# 10, which means the following code:is now equivalent to:_log.Info($"Hello {World()}!");
if (_log.IsInfoEnabled) { _log.Info() .Append("Hello ") .Append(World()) .Append("!") .Log(); }
- The
ILogEvent
interface has been removed, it's replaced by theLogMessage
class, in order to remove slower interface calls. - The
ILog
interface has been removed, it's replaced by theLog
class, for the same reason. - Appenders have been entirely redesinged, and the StringFormatter library has been replaced with built-in .NET 6 formatting features.
- ASCII values have been replaced with UTF-8.
- External JSON configuration has been removed. The library is now configured in code. Live configuration updates are possible (but allocate).
- The library now includes Roslyn analyzers that check for correct usage, and a new code fix for migration to the new syntax. See #45.