nlog

NLog not working with MSTest, where should the config go?

天涯浪子 提交于 2019-12-10 17:33:29
问题 We have recently migrated tests from NUnit to MSTest and I am struggling to get previously passing tests runnning. From what I can deduce MSTest cannot detect the NLog configuration. I have my Nlog configuration in my App.config which didn't cauise an issue with NUnit. Has anyone any ideas? 回答1: Change the Copy to Output Directory setting for your App.config to Copy Always or Copy if Newer . More on this here. 来源: https://stackoverflow.com/questions/4509987/nlog-not-working-with-mstest-where

Assembly from GAC is not listed in Monodevelop's Edit References dialog

扶醉桌前 提交于 2019-12-10 17:19:09
问题 I am trying to port a small console application from Windows/.NET to Ubuntu/Mono. I have problems to add a reference to the mono version of NLog, which I added to the GAC. Adding NLog.dll to the assembly was confirmed: Installed NLog.dll into the gac (/usr/lib/mono/gac) I also find it in the GAC under: /usr/lib/mono/gac/NLog/2.0.0.0__5120e14c03d0593c First I thought that it was due to my umask 027. But I changed files to 644 and directories to 755. The problem persists. I am working with:

Nlog Target Database set connection information at runtime

做~自己de王妃 提交于 2019-12-10 17:10:10
问题 Using Nlog and a Database target, is there a way to set the connection information at runtime? 回答1: I remember some colleague of mine doing something similar. He found this answer: http://nlog-forum.1685105.n2.nabble.com/DDL-for-Database-Table-How-to-set-Connection-String-Programmatically-td5241103.html that was working perfectly fine. From the link above The easiest way of overriding connection string is through the use of GDC: <target name="db" type="Database" connectionString="${gdc

NLog nlogger snippet not working Visual Studio 2012

旧城冷巷雨未停 提交于 2019-12-10 15:07:14
问题 Does anyone know how to get Nlog's nlogger snippet to work in Visual Studio 2012 like it did in 2010? I don't see anything on their forum or on the internet when googing around. Seems like something that people who use Nlog would want back. 回答1: Haven't worked out how to get the real snippet installed, so I manually created a snippet to perform the same function as the original did. Create the file nlogger.snippet in the following folder: My Documents\Visual Studio 2012\Code Snippets\Visual C

A utility to compress rotated log files?

可紊 提交于 2019-12-10 14:44:50
问题 I'm using NLog for logging and need to zip the loads of rotated text files it's generating shortly after they are created. NLog should support this feature some time in the unknown future, but is there a utility of sorts that can do this independently ? 回答1: Zipping archive files is supported since NLog 4.0, see news post Use enableArchiveFileCompression , e.g. <target name="file" xsi:type="File" layout="${longdate} ${logger} ${message}" fileName="${basedir}/logs/logfile.txt" archiveFileName=

How to stack up log messages and log them just when an exception occurs?

自古美人都是妖i 提交于 2019-12-10 05:04:14
问题 I have a business process that executes a bunch of SQL Commands. I want to "stack up" these sql commands in a stack and write them to DB just when an exception occurs, let me explain it with some code public void BusinessMethod() { Log.Initialize(); // Clear the stack try { Method1ThatExecutesSomeSQLs(); Method2ThatExecutesSomeSQLs(); Method3ThatExecutesSomeSQLs(); } catch(Expection ex) { // if some exception occured in any Method above, them i write the log, otherwise, i dont want to log

How do I use Microsoft Application Insights with NLog (Target cannot be found: 'ApplicationInsights')

社会主义新天地 提交于 2019-12-10 02:56:13
问题 I am using Microsoft Application Insights for my Web Application. I used the Application Insights TraceListener NuGet package for logging. That worked perfectly. Now I would like to switch to NLog. I added the Microsoft.ApplicationInsights.NLogTarget NuGet package and added a new NLog target in my NLog configuration file: <target name='ai' xsi:type='ApplicationInsights' /> NLog throws an exception: Target cannot be found: 'ApplicationInsights' I also tried adding the assembly via extensions

Configuring NLog to log exceptions in an XML output?

南楼画角 提交于 2019-12-10 02:27:00
问题 Currently, we have NLog spitting out CSV files just to prove we have NLog actually logging exceptions. <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" internalLogToConsole="true" internalLogToConsoleError="true"> <targets> <target name="file" xsi:type="File" fileName="${specialfolder:folder=ApplicationData}/log.csv"> <layout xsi:type="CSVLayout"> <column name="User_Machine_Name" layout="${machinename}" /> <column name="Time"

How can I query the path to an NLog log file?

十年热恋 提交于 2019-12-09 15:20:20
问题 I've configured a file target for NLog as follows: <targets> <target name="asyncFile" xsi:type="AsyncWrapper"> <target xsi:type="File" name="logfile" fileName="${basedir}/Logs/${shortdate}.log" layout="${longdate} ${uppercase:${level}} ${message}" /> </target> </targets> How can I query the actual filesystem path ( fileName ) of this File target via NLog's API? 回答1: I've just tried to get this information via the configuration api. Sadly it looks like the configuration is evaluated by the

在.net core web 项目中使用Nlog记录日志

蹲街弑〆低调 提交于 2019-12-09 12:42:45
第1步,添加NLog.Web.AspNetCore包引用 方法1 在项目上右击“依赖项”---“管理Nuget程序包(N)…”,然后在浏览对话框中输入“NLog.Web.AspNetCore”查找包,找到后选中并单击“安装”。 方法2 或者直接在包管理器控制台输入以下命令: Install-Package NLog.Web.AspNetCore 第2步,添加Nlog.config配置文件 (1)在项目名称上击右键,选择 ”添加” --- “新建项”。 (2)在弹出的“添加新项”对话框中左边选择“ASP.NET Core”,右边选择“XML文件” ,“名称”框中输入“Nlog.config”,最后单击“添加”按钮。 (3)修改刚添加的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 xsi:type="File" name="logfile" fileName="${basedir}/logs/${shortdate}.log"