nlog

add record in nlog to field with dataType = date

牧云@^-^@ 提交于 2021-02-08 07:24:54
问题 I use nlog dll to write to database - oracle with entity frameWork in the line : logger.Log(logLevel, "try"); I get in the logs of nlog the following error: The literal does not match the template string the code is: SetPropGDC(LogEntity); NLog.LogLevel logLevel = SetLogLevel(Level.Debug); logger.Log(logLevel, "try"); ClearGDC(); private void SetPropGDC(LogEntity LogEntity) { GlobalDiagnosticsContext.Set(processId, LogEntity.PROCESS_ID.ToString()); GlobalDiagnosticsContext.Set("TIME_STAMP",

add record in nlog to field with dataType = date

流过昼夜 提交于 2021-02-08 07:22:14
问题 I use nlog dll to write to database - oracle with entity frameWork in the line : logger.Log(logLevel, "try"); I get in the logs of nlog the following error: The literal does not match the template string the code is: SetPropGDC(LogEntity); NLog.LogLevel logLevel = SetLogLevel(Level.Debug); logger.Log(logLevel, "try"); ClearGDC(); private void SetPropGDC(LogEntity LogEntity) { GlobalDiagnosticsContext.Set(processId, LogEntity.PROCESS_ID.ToString()); GlobalDiagnosticsContext.Set("TIME_STAMP",

Dynamically Set Nlog Log Level per Logger Instance ASP.Net Core 2.x

て烟熏妆下的殇ゞ 提交于 2021-02-07 18:17:34
问题 Objective : To dynamically select which HTTP request I want verbose logging (different log level). Overview : I have a ASP.Net core 2.1 web server running and once in production, if I need to debug an issue I want to be able to change the log level. I have found how to globally change the log level; however, changing the log level is persistent... aka, does not reset after each call to my controller. [HttpGet] public async Task<IEnumerable<string>> Get() { this.Logger.LogTrace("This should

Dynamically Set Nlog Log Level per Logger Instance ASP.Net Core 2.x

天大地大妈咪最大 提交于 2021-02-07 18:17:29
问题 Objective : To dynamically select which HTTP request I want verbose logging (different log level). Overview : I have a ASP.Net core 2.1 web server running and once in production, if I need to debug an issue I want to be able to change the log level. I have found how to globally change the log level; however, changing the log level is persistent... aka, does not reset after each call to my controller. [HttpGet] public async Task<IEnumerable<string>> Get() { this.Logger.LogTrace("This should

Share nlog config with multiple projects and the proper threadsafe way to all write to the same log file?

混江龙づ霸主 提交于 2021-02-07 12:38:50
问题 My program consists of a single EXE and 6 DLLs (and of course everyone references everyone), I currently have a crude static logging class (Logger) which is in its own DLL (Logger.dll) which I add as a reference to each of my projects and use ... but instead of re-inventing the wheel I was looking to replace this with nLog. Problem is I can't seem to figure out how all my projects can share the same nLog config file (I want everything logging to the SAME file and I do not want to define a

你所不知道的Java十种经典排序算法

痞子三分冷 提交于 2021-02-07 12:15:02
算法分类 比较排序:在排序的最终结果里,元素之间的次序依赖于他们之间的比较,每个数必须和其他数进行比较,才能确定自己的位置。 优势:适用于一切需要排序的情况。不在乎数据的分布,适用于各种规模的数据 冒泡排序、快速排序、插入排序、希尔排序 、堆排序、选择排序、归并排序。 在冒泡排序之类的排序中,问题规模为n,又因为需要比较n次,所以平均时间复杂度为O(n²)。在归并排序、快速排序之类的排序中,问题规模通过分治法消减为logN次,所以平均时间复杂度为O(nlogn)。 非比较排序:只要确定每个元素之前的已有的元素个数即可,所有一次遍历即可解决。时间复杂度为O(n)。 计数排序、基数排序、桶排序。 非比较排序的时间复杂度低,但是需要占用空间来确定唯一的位置。 递归factorial 方法内部调用方法本身 ⚠️递归的层级太深容易造成栈内存溢出stackOverFlowError 冒泡排序 一次比较相邻的两个元素,如果第一个比第二个大就交换它们两个。 从第一对到结尾的最后一对,重复比较。 重复前面两个步骤(每次都能找到一轮中的最大值)。 算法分析: 最佳情况:T(n) = O(n) 最差情况:T(n) = O(n²) 平均情况:T(n) = O(n²) public static int [ ] bubbleSort ( int [ ] array ) { if ( array .

Is it possible to mock NLog log methods?

拟墨画扇 提交于 2021-02-07 06:25:41
问题 Is it possible/easy to mock NLog log methods, using Rhino Mocks or similar? 回答1: You can only mock virtual methods. But if You create some interface for logging and then implement it using NLog You can use dependency injection and in Your tests use mocked interface to see if system under test (SUT) is logging what You expect it to log. public class SUT { private readonly ILogger logger; SUT(ILogger logger) { this.logger = logger;} MethodUnderTest() { // ... logger.LogSomething(); // ... } } /

Is it possible to mock NLog log methods?

我只是一个虾纸丫 提交于 2021-02-07 06:25:10
问题 Is it possible/easy to mock NLog log methods, using Rhino Mocks or similar? 回答1: You can only mock virtual methods. But if You create some interface for logging and then implement it using NLog You can use dependency injection and in Your tests use mocked interface to see if system under test (SUT) is logging what You expect it to log. public class SUT { private readonly ILogger logger; SUT(ILogger logger) { this.logger = logger;} MethodUnderTest() { // ... logger.LogSomething(); // ... } } /

NLog IValueFormatter do not output any data?

不羁的心 提交于 2021-01-29 05:14:52
问题 I have the following IValueFormatter : public class NLogValueFormatter : IValueFormatter { public bool FormatValue(object value, string format, CaptureType captureType, IFormatProvider formatProvider, StringBuilder builder) { if (value.GetType() == typeof(LogData)) return false; builder.Append(format); try { var myTarget = LogManager.Configuration.FindTargetByName("communicationFileLog"); myTarget = ((myTarget as NLog.Targets.Wrappers.WrapperTargetBase)?.WrappedTarget) ?? myTarget; var

Change dynamically file path for log files .NET Core + NLog

心已入冬 提交于 2021-01-29 04:15:32
问题 In my .NET Core app I use some environments and I want to do different paths to log files for every environment. For example, Development - c:\logs Staging - d\apps\logs For every environment I have config section in appsettings.{env}.json : "LocalPaths": { "LogFileRootDirectory": "c:\\logs\\" } And part of nlog.config : <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" autoReload="true" internalLogLevel="Warn" internalLogFile="$