nlog

Net Core NLog.Web “aspnet-user-identity” is empty?

ぐ巨炮叔叔 提交于 2020-06-27 08:16:40
问题 I was using "NLog.Extensions.Logging" for logging and need to log user identity and found that it is possible with "NLog.Web.AspNetCore". "nlog.config" file is configured to log the "aspnet-user-identity". However, when I look at logs, user identity part is always empty string, the other columns are look pretty good. Am I missing something? A part of my configuration file is here: <extensions> <assembly="NLog.Web.AspNetCore" /> </extensions> <parameter name="@identity" layout="${aspnet-user

NLog not writing debug messages

左心房为你撑大大i 提交于 2020-06-27 08:13:06
问题 In my code I have some info messages like logger.Log("dwewe") and logger.Debug("ddddf") . The problem is that the Debug messages are not being written even when I debug in VS. <?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" throwExceptions="true" internalLogLevel="Trace" internalLogFile="c:\nlog-app.log" autoReload="false" internalLogToConsole="true"> <!-- See http://nlog-project.org/wiki

NLog Inner Exception Loggin

最后都变了- 提交于 2020-06-12 02:14:53
问题 I'm trying to log inner exception messages by using NLog. This is a piece of my NLog.config file: <target name="errors" xsi:type="File" layout="${longdate}${newline} - Exception Message: ${exception:format=Message}${newline} - InnerException Message: ${exception:innerExceptionSeparator=TEXT}${newline}" fileName="\Logs\errors-${shortdate}.log" concurrentWrites="true" /> </targets> I'm getting the same message See the inner exception for details for both Exception Message and InnerException

Set ValueFormatter for specific NLog instance?

半腔热情 提交于 2020-06-01 05:06:43
问题 I have 2 NLog instances where one needs a special ValueFormatter to serialize parameters. The ValueFormatter is set with this code : NLog.Config.ConfigurationItemFactory.Default.ValueFormatter = new NLogValueFormatter(); So as you can see it will be applied to all loggers. I can´t find any property on the NLogger itself that might take a ValueFormatter. Is there any way to bind this ValueFormatter just to one of the loggers? Edit 1: private CommunicationFormatProvider provider = new

Set ValueFormatter for specific NLog instance?

℡╲_俬逩灬. 提交于 2020-06-01 05:06:06
问题 I have 2 NLog instances where one needs a special ValueFormatter to serialize parameters. The ValueFormatter is set with this code : NLog.Config.ConfigurationItemFactory.Default.ValueFormatter = new NLogValueFormatter(); So as you can see it will be applied to all loggers. I can´t find any property on the NLogger itself that might take a ValueFormatter. Is there any way to bind this ValueFormatter just to one of the loggers? Edit 1: private CommunicationFormatProvider provider = new

Layout NLog properties as JSON?

五迷三道 提交于 2020-05-27 05:49:45
问题 I am trying to figure out how to log all the properties in a LogEventInfo object to a JSON-formatted string. Per the issue on github, I tried to do something like this: <target xsi:type="ColoredConsole" name="coloredConsole"> <layout xsi:type="JsonLayout"> <attribute name="timestamp" layout="${longdate}"/> <attribute name="level" layout="${level:uppercase=true}"/> <attribute name="exception" layout="${onexception:${exception:format=tostring}}" /> <attribute name="properties" encode="false">

Unable to save aspnet-sessionid using NLog

非 Y 不嫁゛ 提交于 2020-05-24 06:08:31
问题 I'm working with Nlog logging framework. currently I'm facing issue, that unable to save aspnet-sessionid. <target xsi:type="File"name="LogFileAppender"fileName="C:\Users\acer\Downloads\test1.txt" layout="${longdate} ${aspnet-sessionid} - ${message} "/> It is saving (as per layout) in target fileName like 2020-05-07 11:16:56.4047 - Global.asax.cs:Application_Start(): Application initializing, starting cache load But in log4net I'm able to save aspnet-sessionid <appender name="LogFileAppender"

How to serialize object fields with NLog?

折月煮酒 提交于 2020-05-17 06:37:05
问题 Im testing out the new structured logging but do not really get it right. I have this in my nlog.config : <target xsi:type="File" name="f" fileName="${basedir}/logs/${shortdate}.log"> <layout xsi:type="JsonLayout" includeAllProperties="true">${longdate}|${level}|${logger}|${message}</layout> </target> <logger name="CommunicationLogger" minlevel="Info" writeto="f"></logger> My log code looks like this : public void LogCommunication(string operation, List<object> args) { var parameters = new

Manage logging configuration with NLog in .NET Core 3

旧街凉风 提交于 2020-05-14 09:39:07
问题 I'm using NLog in a .NET Core 3.1 worker service application. Following the tutorial of NLog I inserted an nlog.config file to manage the configuration. Now I'm confused because I have three points where I configure the logging: 1. In the code where I need to create a logger in a dependency injection context // Other code... services.AddScoped<IApplyJcdsCommandsJob, ApplyJcdsCommandsJob>(provider => { var loggerFactory = LoggerFactory.Create(builder => { builder .ClearProviders() .AddFilter(

Print a multi-line message with NLog

点点圈 提交于 2020-05-11 07:21:41
问题 Is it possible with NLog to emit a multi-line message such that each line is formatted according to the current layout? E.g. 2015-12-17 11:37:38.0845 | 64 | INFO | ----------------------------------- 2015-12-17 11:37:38.0845 | 64 | INFO | Statistics: 2015-12-17 11:37:38.0845 | 64 | INFO | Crawling Requests 46887 /min 2015-12-17 11:37:38.0845 | 64 | INFO | Stored Documents 9910 /min 2015-12-17 11:37:38.0845 | 64 | INFO | ----------------------------------- Alternatively, is it possible with