NeonLog.CSharp
0.1.0-ci.40
See the version list below for details.
dotnet add package NeonLog.CSharp --version 0.1.0-ci.40
NuGet\Install-Package NeonLog.CSharp -Version 0.1.0-ci.40
<PackageReference Include="NeonLog.CSharp" Version="0.1.0-ci.40" />
<PackageVersion Include="NeonLog.CSharp" Version="0.1.0-ci.40" />
<PackageReference Include="NeonLog.CSharp" />
paket add NeonLog.CSharp --version 0.1.0-ci.40
#r "nuget: NeonLog.CSharp, 0.1.0-ci.40"
#:package NeonLog.CSharp@0.1.0-ci.40
#addin nuget:?package=NeonLog.CSharp&version=0.1.0-ci.40&prerelease
#tool nuget:?package=NeonLog.CSharp&version=0.1.0-ci.40&prerelease
C# wrapper
This folder contains a thin C# wrapper for neonlog-c built with P/Invoke against the stable C ABI exported from include/neonlog/neonlog.h.
Projects
NeonLog.CSharptargetsnetstandard2.0and exposes managed logger, factory, sink, and value types.NeonLog.CSharpnow also includesNeonLogConfigurationOptionsandNeonLogPropertyOptionsso appsettings-bound configuration can live in the wrapper instead of the sample.NeonLog.CSharpcan now read both the wrapper-native options shape and the original NeonLogWriteTo/Properties/Enrichsettings shape throughNeonLogConfigurationOptions.FromConfiguration(...).NeonLog.CSharpalso integrates withMicrosoft.Extensions.Logging, so the package can be registered as the app's standardILoggerprovider withbuilder.Logging.AddNeonLog(...).NeonLog.CSharp.Sampleis a console app that bindsNeonLogConfigurationOptionsfromappsettings.jsonand exercises the factory API from C#.NeonLog.CSharp.PackageTestsis an xUnit consumer project that restores the packed NuGet package from the local package feed and exercises the full supported API surface.
Package layout
NeonLog.CSharp is now packable as a single NuGet package that contains:
- the managed
netstandard2.0wrapper assembly runtimes/win-x64/native/neonlog.dllruntimes/linux-x64/native/libneonlog.so
GitHub Actions CI
The repository CI is defined in .github/workflows/ci.yml and does the entire packaging flow in GitHub Actions:
- builds and smoke-tests the native library on
windows-latest - builds and smoke-tests the native library on
ubuntu-latest - stages the platform binaries into
artifacts/native/<rid> - packs
NeonLog.CSharpinto a NuGet package that includes both native assets - runs the package-consumer tests on Windows and Linux against the packed
.nupkg - publishes the
.nupkgto GitHub Packages on tags matchingv*
Every CI run also uploads the native binaries and the generated .nupkg as workflow artifacts.
The project expects staged native assets at:
artifacts/native/win-x64/neonlog.dllartifacts/native/linux-x64/libneonlog.so
The generated .nupkg is written to artifacts/packages.
Build native assets
Stage the Windows native binary from Windows:
./bindings/dotnet/scripts/build-and-stage-native.ps1 -Configuration Release
Stage the Linux native binary from Linux:
./bindings/dotnet/scripts/build-and-stage-native.sh Release
Both files must be present before dotnet pack runs.
Pack the NuGet package
With both native assets staged and a .NET SDK installed:
dotnet pack bindings/dotnet/NeonLog.CSharp/NeonLog.CSharp.csproj -c Release
The pack target fails fast if either the Windows or Linux native asset is missing.
In GitHub Actions, the package version defaults to 0.1.0-ci.<run_number> for branch and pull request builds and uses the tag value for refs like v0.1.0.
Run the package consumer tests
The test project references NeonLog.CSharp via PackageReference, not via project reference. Restore and test it only after packing the local package:
dotnet test bindings/dotnet/NeonLog.CSharp.PackageTests/NeonLog.CSharp.PackageTests.csproj -c Release
The tests cover:
- ABI/version metadata lookup
- direct logger creation and configuration
- context loggers
- all log level helper methods
- all supported value kinds
- factory configuration with static properties
- console sink configuration
- original-style
WriteTo/Enrichconfiguration parsing - both Redis modes with sink-error isolation
- async-mode rejection
Original NeonLog compatibility
The wrapper now mirrors these original NeonLog configuration concepts directly:
WriteTo: [{ Name, Args }]forConsole,Redis, andRedisListPropertiesas a simple object mapEnrichwithTimestamp,ProcessInfo,Environment,LogScope, andHttpRequestoutputTemplateon the console sink
Use NeonLogConfigurationOptions.FromConfiguration(...) when you want the wrapper to accept the same NeonLog section shape used by the Node.js package.
LogScope and HttpRequest are implemented in managed code with AsyncLocal helpers:
NeonLogScopeNeonLogHttpRequestContext
Microsoft ILogger integration
Use the wrapper as the application's standard logging provider:
using NeonLog;
var neonLogOptions = NeonLogConfigurationOptions
.FromConfiguration(builder.Configuration.GetSection("NeonLog"));
builder.Logging.ClearProviders();
builder.Logging.AddNeonLog(neonLogOptions.ToFactoryOptions());
Or bind directly from configuration:
builder.Logging.AddNeonLog(builder.Configuration.GetSection("NeonLog"));
The provider maps:
ILogger<T>categories toSourceContext- structured message templates to native NeonLog template arguments
BeginScope(...)values to per-event context propertiesEventId.Id/EventId.NametoEventId/EventNameLogLevel.CriticaltoFatal
Redis fallback buffering
NeonLogRedisSinkOptions now supports two failure-handling settings for sinks like Redis:
FallbackToConsoleOnFailure: redirects buffered events to the console when Redis cannot connect or flush and no regular console sink is already configured.MaxBufferedEvents: caps the in-memory Redis backlog so the sink keeps only a bounded recent buffer instead of retaining every unsent event.
When fallback is enabled and Redis becomes unavailable, buffered events are written to the console and cleared instead of being retained indefinitely.
In CI, these tests restore NeonLog.CSharp from the just-packed local artifact feed under artifacts/packages so the package, not the source project, is what gets validated.
Build and run the sample
Build or stage a native library for your current platform.
cmake -S . -B build cmake --build build --config DebugMake the native library discoverable to the CLR at runtime. On Windows that typically means copying
build\Debug\neonlog.dllnext to the managed executable or adding that directory toPATH.Build and run the sample with a .NET SDK installed:
dotnet build bindings/dotnet/NeonLog.CSharp.Sample/NeonLog.CSharp.Sample.csproj dotnet run --project bindings/dotnet/NeonLog.CSharp.Sample/NeonLog.CSharp.Sample.csproj
Managed API surface
NeonLogRuntimevalidates ABI compatibility and exposes native status and level names.NeonLoggerFactorywrapsneonlog_logger_factory_*for advanced sink configuration.NeonLoggerwraps both the direct config API and the logger API, including child loggers, level checks, and flush.NeonLogValuemarshals UTF-8 strings, integers, doubles, booleans, and null values into the native union type.
| 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 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. |
| .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 was computed. |
| .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 (>= 8.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Logging (>= 8.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on NeonLog.CSharp:
| Package | Downloads |
|---|---|
|
NeonLog.CSharp.AspNetCore
ASP.NET Core request logging middleware for neonlog-c. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.0-ci.88 | 71 | 7/6/2026 |
| 0.1.0-ci.87 | 193 | 6/16/2026 |
| 0.1.0-ci.86 | 136 | 6/15/2026 |
| 0.1.0-ci.84 | 78 | 6/12/2026 |
| 0.1.0-ci.82 | 72 | 6/11/2026 |
| 0.1.0-ci.80 | 65 | 6/11/2026 |
| 0.1.0-ci.79 | 74 | 6/11/2026 |
| 0.1.0-ci.78 | 87 | 6/8/2026 |
| 0.1.0-ci.75 | 70 | 6/8/2026 |
| 0.1.0-ci.73 | 80 | 6/5/2026 |
| 0.1.0-ci.70 | 73 | 6/5/2026 |
| 0.1.0-ci.66 | 67 | 6/4/2026 |
| 0.1.0-ci.64 | 78 | 6/4/2026 |
| 0.1.0-ci.63 | 64 | 6/4/2026 |
| 0.1.0-ci.61 | 75 | 6/3/2026 |
| 0.1.0-ci.60 | 59 | 6/3/2026 |
| 0.1.0-ci.58 | 66 | 6/3/2026 |
| 0.1.0-ci.55 | 66 | 6/3/2026 |
| 0.1.0-ci.54 | 60 | 6/2/2026 |
| 0.1.0-ci.40 | 55 | 6/2/2026 |