Jx.Log.LogClient
0.3.2-sec
This is a prerelease version of Jx.Log.LogClient.
dotnet add package Jx.Log.LogClient --version 0.3.2-sec
NuGet\Install-Package Jx.Log.LogClient -Version 0.3.2-sec
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="Jx.Log.LogClient" Version="0.3.2-sec" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Jx.Log.LogClient --version 0.3.2-sec
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Jx.Log.LogClient, 0.3.2-sec"
#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 Jx.Log.LogClient as a Cake Addin #addin nuget:?package=Jx.Log.LogClient&version=0.3.2-sec&prerelease // Install Jx.Log.LogClient as a Cake Tool #tool nuget:?package=Jx.Log.LogClient&version=0.3.2-sec&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
使用 jx.logClient
jx.logClient 基于 .NET Standard 开发,目的是为 .NET Core 2.0 项目,简化“统一日志服务”的接入。
Nuget包页面: https://www.nuget.org/packages/Jx.Log.LogClient
接入方法
- 引用 Nuget 包
- 配置 JxLogClient
- 输出日志
引用 Nuget 包
在 Visual Studio 的 Package Manager Console 中:
PM> Install-Package Jx.Log.LogClient
在命令行中:
D:\temp>dotnet new console -o jxLogClientTest
D:\temp>cd jxLogClientTest
D:\temp\jxLogClientTest>dotnet add package Jx.Log.LogClient
D:\temp\jxLogClientTest> 为排版需要,删除了所有命令的输出
配置 JxLogClient
using System;
using jx.logClient;
namespace jxLogClientTest
{
class Program
{
static void Main(string[] args)
{
// 此处仅作示意,实际项目应该从配置文件中读取
var logConfig = new JxLogConfig
{
AppId = "testing",
RedisHost = "192.168.8.173",
RedisInstance = "LogService:Logs", // 需要与 LogAgent 配置相同
LogLevel = "Info",
Env = "Development"
};
JxLogClient.Init(logConfig);
}
}
}
注意:JxLogClient.Init
为静态方法,此方法要在任何使用 JxLog.Instance
的代码之前调用,AppId
由日志中心分发,其本身是个字符串
输出日志
using System;
using jx.logClient;
namespace jxLogClientTest
{
class Program
{
static void Main(string[] args)
{
// 此处仅作示意,实际项目应该从配置文件中读取
var logConfig = new JxLogConfig
{
AppId = "testing",
RedisHost = "192.168.8.173:6379",
RedisInstance = "LogService:Logs", // 需要与 LogAgent 配置相同
LogLevel = "Info",
Env = "Development"
};
JxLogClient.Init(logConfig);
JxLog.Info("Hello from jxLogClientTest");
LogCostTimeWithWarn(300);
Console.WriteLine("please enter something as log, Enter to send");
while (true)
{
Console.Write("> ");
var line = Console.ReadLine();
JxLog.Info(line);
if ("exit" == line)
break;
}
}
static void LogCostTimeWithWarn(int milliSeconds)
{
var logger = JxLog.StartTimer();
System.Threading.Thread.Sleep(milliSeconds);
logger.LogWarn($"slept {milliSeconds}ms");
}
}
}
在命令行中运行程序
D:\temp\jxLogClientTest>dotnet run
please enter something as log, Enter to send
> Hello from windows command line.
> exit
D:\temp\jxLogClientTest>
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. |
.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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- Microsoft.AspNetCore.Http.Abstractions (>= 1.0.0)
- Newtonsoft.Json (>= 10.0.3)
- StackExchange.Redis (>= 1.2.6)
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.3.2-sec | 833 | 6/21/2018 |
0.3.1 | 1,160 | 5/10/2018 |
0.3.0 | 1,180 | 5/10/2018 |
0.2.2 | 1,149 | 9/28/2017 |
0.2.1 | 928 | 9/28/2017 |
0.2.0 | 1,046 | 9/28/2017 |
0.2.0-alpha | 726 | 9/27/2017 |
0.1.0 | 981 | 9/25/2017 |
0.1.0-alpha | 807 | 9/22/2017 |
remove millisecond part from DateFormatString.