NLog.NetworkTarget 1.0.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package NLog.NetworkTarget --version 1.0.0.2
                    
NuGet\Install-Package NLog.NetworkTarget -Version 1.0.0.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="NLog.NetworkTarget" Version="1.0.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NLog.NetworkTarget" Version="1.0.0.2" />
                    
Directory.Packages.props
<PackageReference Include="NLog.NetworkTarget" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add NLog.NetworkTarget --version 1.0.0.2
                    
#r "nuget: NLog.NetworkTarget, 1.0.0.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.
#:package NLog.NetworkTarget@1.0.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=NLog.NetworkTarget&version=1.0.0.2
                    
Install as a Cake Addin
#tool nuget:?package=NLog.NetworkTarget&version=1.0.0.2
                    
Install as a Cake Tool

NLog.NetworkTarget

编辑 nlog.config


	<extensions>
		<add assembly="NLog.NetworkTarget"/>
	</extensions>
	<targets async="true">
		<target xsi:type="JsonNetwork" name="server" address="http post 地址" layout="${jsonnetwork}" />
	</targets>
	<rules>
		<logger name="*" minlevel="Info" writeTo="server"/>
	</rules>

完整文档


<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      autoReload="true"
      internalLogLevel="Info"
      internalLogFile="/var/log/parking/internal-nlog.txt">

	
	<extensions>
		<add assembly="NLog.Web.AspNetCore"/>
		<add assembly="NLog.NetworkTarget"/>
	</extensions>
	<variable name="logdir" value="/var/log/parking/"/>
	
	<targets async="true">
		
		<target xsi:type="File" name="ownFile-web" fileName="${logdir}/${shortdate}.log"
				layout="${longdate}|${logger}|${uppercase:${level}}|${callsite:className=false:fileName=true:includeSourcePath=false:methodName=true}${newline}${message} ${exception}${newline}" />

		<target xsi:type="JsonNetwork" name="server" address="地址" layout="${jsonnetwork}" />

		
		<target xsi:type="Null" name="blackhole" />
	</targets>

	
	<rules>
		
		<logger name="*" minlevel="Info" writeTo="server"/>
		<logger name="*" minlevel="Info" writeTo="ownFile-web" />
	</rules>
</nlog>

Program


	LoggerFormat.ArgsName = new string[] { "RobotId", "Plate" };

写日志


	_logger.LogInformation($"{LoggerFormat.Write("0575aa74-f4d7-49f7-a052-17b3cf5bebb1", "川Z00000")}这里开始写入日志文件的内容");

write 写入参数顺序 按 LoggerFormat.ArgsName 定义顺序传入

日志写入后效果

日志文件效果

2024-08-01 21:03:15.9674|TestController|INFO|gc(TestController.cs:90)
这里开始写入日志文件的内容 

日志服务器接受到数据效果


{"Time":ISODate("2024-08-01T21:30:04.806Z"),"Level":"Info","RobotId":"0575aa74-f4d7-49f7-a052-17b3cf5bebb1","Plate":"川Z00000","Message":"这里开始写入日志文件的内容"}
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
1.0.1.6 149 3/13/2026
1.0.1.5 441 8/8/2024
1.0.1.4 189 8/8/2024
1.0.1.3 183 8/7/2024
1.0.1.2 187 8/7/2024
1.0.1.1 156 8/6/2024
1.0.0.2 161 8/1/2024
1.0.0.1 149 8/1/2024