nlog

数据结构(堆)

烈酒焚心 提交于 2019-12-14 21:47:38
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 定义: 数据结构中的堆是一种特殊的二叉树。 堆 必须符合以下两个条件: 是一棵完全二叉树。 任意一个节点的值都大于(或小于)左右子节点的值。 从第一点可以知道,堆适合用数组来存储。 第二点中,若父节点都大于等于左右子节点,则被称为大顶堆,反之则为 小顶堆。 堆的实现方案 堆的存储 完全二叉树采用数组存储最省空间,并且对 CPU 缓存 比 链表 友好。 如图,采用数组表示并空出 0 号位置,节点 i 的父节点为 2xi ,左右子节点分别为 i/2 和 i/2+1 。 堆的操作—插入数据 在堆尾(即数组末尾)插入数据,会导致破坏堆的特性,如图: 因此需要将被破坏的堆重新调整为堆,这个过程被称为堆化,堆化的操作可以自上而下,也可以自下而上。 图中插入元素8后,打破了大顶堆的特性,将元素8向上与其父节点比较,判断是否交换,若交换,则继续向上比较,直到所有父子节点符合要求。 代码实现(大顶堆): public class Heap { private int[] heapData; // 数组,从下标 1 开始存储数据 private int n; // 堆可以存储的最大数据个数 private int count; // 堆中已经存储的数据个数 public Heap(int capacity) { heapData

NLog not Logging in Simple App

血红的双手。 提交于 2019-12-14 04:02:21
问题 I am trying to implement a simple log using Nlog 1.0, using the following code Dim _logger = LogManager.GetCurrentClassLogger() _logger.Debug("Iain") And the following NLog.config. <?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" > <targets> <target name="file" xsi:type="File" fileName="${basedir}/Site.log" layout="${date}: ${message}"/> <target name="eventlog" xsi:type="EventLog" source=

Can NLog v2 be used with Common.Logging

狂风中的少年 提交于 2019-12-14 03:40:50
问题 I tried using these together today, and was getting a version mismatch, as it's looking for NLog v1. Does Common.Logging support NLog v2 yet? If not, does anyone know if an assembly version redirect can safely be used? 回答1: You can simply do assembly redirect in app.config or web.config, and CommonLogging will just work fine with NLog2 by using NLog2 as logging framework: <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="NLog"

NLog callback possible?

Deadly 提交于 2019-12-14 03:17:13
问题 I am in the process of converting a home grown logging system to NLog and am wondering if there is a way to add an event to a Logger or otherwise support a mechanism where when I log a message I can get a callback with the final formatted message and the LogLevel. I currently use something like this to send server messages back to a connected client. Thx 回答1: This is an MCVE of what I was talking about in the comments. Create a target that accepts some callback functions: [Target("MyFirst")]

Reference to Projects which have references to the same dll with different versions

岁酱吖の 提交于 2019-12-13 19:30:11
问题 in my c# class lib i have referenced different Projects which have references to the same dll with different versions. Both references the nlog.dll but one project version 2.1 and the other 4.2. The referenced project are class libs, too. Most of them are .net 2.0 and some 4.5. 回答1: Just make a Libraries folder if you need to and then create a version folder structure and 'add reference' to each project. If these are nuget packages then you shouldnt need to do this. 回答2: You need to install

What's the meaning of the time stamp in nlog when async is on?

两盒软妹~` 提交于 2019-12-13 16:26:01
问题 I'm a little confused about NLog's behivor when I set async=true in NLog's configuration file. Is the timestamp in the log file present the time when logger.Debug/Error/Info/Trace is called, or is it the time that the log got written from buffer to file on the file system? Answer Nlog Async and Log Sequence mentioned that the order of the log sequence is not guaranteed when async is on, is that true? If I set async=true , does it has influence to the result when doing performance testing? 回答1

Logging Library for .NET Compact Framework? [closed]

为君一笑 提交于 2019-12-13 14:14:43
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . Any good logging libraries that support .NET compact framework? 回答1: log4net is a good choice, I use it for all projects. 回答2: Nlog does too. There are some functionalities not available in compact network (logging of Exception instances out of the box for example). 回答3: log4net actually supports compact

How can I enable Security in LogReceiverService (NLog)

蓝咒 提交于 2019-12-13 04:24:06
问题 I have to make a centralized log repository and I decided to mount a WCF service implementing NLog's LogReceiverService (through wsHttpBinding). I followed this topic where I found a working example (there is a working code at bitbucket). Ok, now the problem: I would like to add some security to this WCF Service, expose it through HTTPS and maybe add an Authentication Token. I have programmed this kind of authentication earlier, so I do know how to do it, it's just I don't know how can I

Custom target not working

余生颓废 提交于 2019-12-13 03:59:32
问题 I am trying to implement the solution that was posted in response to this question but it is not working. My objective is to log to a file (working) and also have the LogHandler methods fire (not working). class Program { private static Logger Logger; static void Main(string[] args) { Target.Register<CallbackTarget>("CallbackTarget"); // https://github.com/NLog/NLog/wiki/Register-your-custom-component LogManager.Configuration.AddTarget("CallbackTarget", new CallbackTarget(LogHandlerA,

NLog: How to use different layout for different levels?

不羁岁月 提交于 2019-12-13 03:33:18
问题 I saw this old question: How to apply different layouts to the same target in NLog? The answer was: to use different targets for different levels. I'm not sure this will always work correctly. A lot of time has passed since. Maybe now there is a better way? 回答1: You could create a custom layout, which has conditions. It will look like the CompoundLayout e.g. <layout type='ConditionalLayout'> <if condition=""> <layout type='JsonLayout'> ...</layout> </if> <if condition=""> <layout type=