CNative.Logging.Extensions
0.7.2
.NET Standard 2.1
This package targets .NET Standard 2.1. The package is compatible with this framework or higher.
.NET Framework 4.5.1
This package targets .NET Framework 4.5.1. The package is compatible with this framework or higher.
Suggested Alternatives
dotnet add package CNative.Logging.Extensions --version 0.7.2
NuGet\Install-Package CNative.Logging.Extensions -Version 0.7.2
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="CNative.Logging.Extensions" Version="0.7.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CNative.Logging.Extensions --version 0.7.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: CNative.Logging.Extensions, 0.7.2"
#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.
// Install CNative.Logging.Extensions as a Cake Addin #addin nuget:?package=CNative.Logging.Extensions&version=0.7.2 // Install CNative.Logging.Extensions as a Cake Tool #tool nuget:?package=CNative.Logging.Extensions&version=0.7.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
DotNetty.Wraper
Description
将微软的Azure/DotNetty 代码重新整理,支持netstandard2.0;net472;net45,可以直接在各个 版本中使用。 并将多个类库合并成到一个项目中,加了些封装类,开箱即用。
封装类的示例:
Client
using DotNetty.Wraper;
using Examples.Common;
using Microsoft.Extensions.Logging;
using System;
using System.IO;
using System.Net;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
namespace TcpSocket.Client
{
class Program
{
static async Task Main(string[] args)
{
ILogger _logger = new CNative.Logging.ConfigLogger();// LoggingHelper.Logger;
X509Certificate2 cert = null;
if (ClientSettings.IsSsl)
{
cert = new X509Certificate2(Path.Combine(ExampleHelper.ProcessDirectory, "dotnetty.com.pfx"), "password");
}
var theClientBuild = SocketBuilderFactory.GetTcpSocketClientBuilder(new IPEndPoint(Examples.Common.ClientSettings.Host, Examples.Common.ClientSettings.Port));
theClientBuild
//.AddLast("framing-enc", new DotNetty.Codecs.LengthFieldPrepender(2))
//.AddLast("framing-dec", new DotNetty.Codecs.LengthFieldBasedFrameDecoder(ushort.MaxValue, 0, 2, 0, 2))
.OnChannelRegistered((client, channel) =>
{
_logger.LogDebug("OnChannelRegistered: " + channel.Id);
})
.OnChannelRegistered((client, channel) =>
{
_logger.LogDebug("OnChannelRegistered: " + channel.Id);
})
.OnClientStarted(client =>
{
_logger.LogInformation($"客户端启动");
client.Send("Hello world" + DateTime.Now);
})
.OnClientClose(client =>
{
_logger.LogInformation($"客户端关闭");
})
.OnException(ex =>
{
_logger.LogError($"异常:{ex.Message}");
})
.OnRecieve((client, bytes) =>
{
_logger.LogInformation($"客户端:收到数据:{Encoding.UTF8.GetString(bytes)}");
client.Send("Hello world " + DateTime.Now);
})
.OnSend((client, bytes) =>
{
_logger.LogInformation($"客户端:发送数据:{Encoding.UTF8.GetString(bytes)}");
});
var theClient = await theClientBuild .BuildAsync(null, (pipeline) =>
{
pipeline.AddLast("framing-enc", new DotNetty.Codecs.LengthFieldPrepender(2));
pipeline.AddLast("framing-dec", new DotNetty.Codecs.LengthFieldBasedFrameDecoder(ushort.MaxValue, 0, 2, 0, 2));
}, ClientSettings.UseLibuv, cert);
//.BuildAsync((tcpCleint) => { return new EchoClientHandler(tcpCleint as IChannelEvent); });
//while (true)
//{
// await theClient.Send(Guid.NewGuid().ToString());
// await Task.Delay(1000);
//}
Console.ReadLine();
theClient?.Close();
}
}
}
Server
using System;
using System.IO;
using System.Net;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
using DotNetty.Wraper;
using Examples.Common;
using Microsoft.Extensions.Logging;
namespace TcpSocket.Server
{
class Program
{
static async Task Main(string[] args)
{
ILogger _logger = new CNative.Logging.ConfigLogger();// LoggingHelper.Logger;
X509Certificate2 tlsCertificate = null;
if (ServerSettings.IsSsl)
{
tlsCertificate = new X509Certificate2(Path.Combine(ExampleHelper.ProcessDirectory, "dotnetty.com.pfx"), "password");
}
var theServerBuild = SocketBuilderFactory.GetTcpSocketServerBuilder(Examples.Common.ServerSettings.Port);
theServerBuild
//.AddLast(new DotNetty.Handlers.Logging.LoggingHandler("SRV-CONN"))
//.AddLast("framing-enc", new DotNetty.Codecs.LengthFieldPrepender(2))
//.AddLast("framing-dec", new DotNetty.Codecs.LengthFieldBasedFrameDecoder(ushort.MaxValue, 0, 2, 0, 2))
.OnConnectionClose((server, connection) =>
{
_logger.LogInformation($"连接关闭,连接名[{connection.ConnectionName}],当前连接数:{server.GetConnectionCount()}");
})
.OnException(ex =>
{
_logger.LogError($"服务端异常:{ex.Message}");
})
.OnChannelRegistered((server, channel) =>
{
_logger.LogDebug("ChannelUnregistered: " + channel.Id);
})
.OnChannelRegistered((server, channel) =>
{
_logger.LogDebug("ChannelRegistered: " + channel.Id);
})
.OnNewConnection((server, connection) =>
{
connection.ConnectionName = $"名字{connection.ConnectionId}";
_logger.LogInformation($"新的连接[{connection.ClientAddress.Address.MapToIPv4().ToString()}]:{connection.ConnectionName},当前连接数:{server.GetConnectionCount()}");
})
.OnRecieve((server, connection, bytes) =>
{
_logger.LogInformation($"服务端:数据{Encoding.UTF8.GetString(bytes)}");
connection.Send(bytes);
})
.OnSend((server, connection, bytes) =>
{
_logger.LogInformation($"向连接名[{connection.ConnectionName}]发送数据:{Encoding.UTF8.GetString(bytes)}");
})
.OnServerStarted(server =>
{
_logger.LogInformation($"服务启动");
});
var theServer = await theServerBuild.BuildAsync(null, (pipeline) =>
{
pipeline.AddLast(new DotNetty.Handlers.Logging.LoggingHandler("SRV-CONN"));
pipeline.AddLast("framing-enc", new DotNetty.Codecs.LengthFieldPrepender(2));
pipeline.AddLast("framing-dec", new DotNetty.Codecs.LengthFieldBasedFrameDecoder(ushort.MaxValue, 0, 2, 0, 2));
}, ServerSettings.UseLibuv, tlsCertificate, 100, 1);
//.BuildAsync((tcpServer) => { return new EchoServerHandler(tcpServer as IChannelEvent, ServerSettings.UseLibuv, 100, 1); });
Console.ReadLine();
theServer?.Close();
}
}
}
DotNetty Project
DotNetty.Wraper is a port of Netty, asynchronous event-driven network application framework for rapid development of maintainable high performance protocol servers & clients.
Use
Contribute
We gladly accept community contributions.
- Issues: Please report bugs using the Issues section of GitHub
- Source Code Contributions:
- Please follow the Contribution Guidelines for Microsoft Azure open source that details information on onboarding as a contributor
- See C# Coding Style for reference on coding style.
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. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
.NET Framework | net451 is compatible. net452 was computed. net46 was computed. 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 | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETFramework 4.5.1
- log4net (>= 2.0.14)
- Microsoft.Extensions.Configuration (>= 1.1.2)
- Microsoft.Extensions.Configuration.Json (>= 1.1.2)
- Microsoft.Extensions.DependencyInjection (>= 1.1.1)
- Microsoft.Extensions.Logging (>= 1.1.2)
- Microsoft.Extensions.Logging.Console (>= 1.1.2)
- Microsoft.Extensions.Logging.Debug (>= 1.1.2)
- Newtonsoft.Json (>= 13.0.1)
- NLog (>= 4.7.15)
- NLog.Config (>= 4.7.15)
- NLog.Extensions.Logging (>= 1.7.4)
- NLog.Targets.ElasticSearch (>= 6.1.0)
- Serilog (>= 2.11.0)
- Serilog.Formatting.Elasticsearch (>= 8.0.1)
- Serilog.Settings.Configuration (>= 3.3.0)
- Serilog.Sinks.Console (>= 4.0.1)
- Serilog.Sinks.RollingFile (>= 3.3.0)
-
.NETStandard 2.1
- Exceptionless (>= 4.6.2)
- Exceptionless.AspNetCore (>= 4.6.2)
- Exceptionless.Extensions.Logging (>= 4.6.2)
- Exceptionless.NLog (>= 4.6.2)
- log4net (>= 2.0.14)
- Microsoft.CSharp (>= 4.7.0)
- Microsoft.Extensions.Configuration (>= 6.0.0)
- Microsoft.Extensions.Configuration.Json (>= 6.0.0)
- Microsoft.Extensions.DependencyInjection (>= 6.0.0)
- Microsoft.Extensions.Logging (>= 6.0.0)
- Microsoft.Extensions.Logging.Console (>= 6.0.0)
- Microsoft.Extensions.Logging.Debug (>= 6.0.0)
- Newtonsoft.Json (>= 13.0.1)
- NLog (>= 4.7.15)
- NLog.Config (>= 4.7.15)
- NLog.Extensions.Logging (>= 1.7.4)
- NLog.Targets.ElasticSearch (>= 7.7.0)
- Serilog (>= 2.11.0)
- Serilog.Extensions.Logging (>= 3.1.0)
- Serilog.Formatting.Elasticsearch (>= 8.4.1)
- Serilog.Settings.Configuration (>= 3.3.0)
- Serilog.Sinks.Console (>= 4.0.1)
- Serilog.Sinks.RollingFile (>= 3.3.0)
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 | |
---|---|---|---|
0.7.2 | 558 | 5/15/2022 |