nlog

Delete log files after x days

谁说我不能喝 提交于 2019-11-27 01:13:36
问题 I would like to log with Nlog using the file target like in this example. How can I realize a deletion of the files after X days without archiving them? Or is it possible to archive the files to the same folder? 回答1: You could simply use the built-in archiving functionality. This setting will keep 7 old log files in addition to your current log. The cleanup is done by NLog automatically. <?xml version="1.0" ?> <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3

Add / remove logfiles during runtime in NLog

懵懂的女人 提交于 2019-11-27 00:36:15
问题 I'm writing a small file conversion utility. Files get automatically converted when they are dropped into a directory. I'm using NLog for logging. Besides a central log file which is configured using NLog.conf (and which receives all messages generated), I'd like to create one additional log file for each input file, having a similar name and containing all log messages written during the conversion process. Unfortunately I seem to be unable to find out how to properly add a new file target

Logging in multiple files using Nlog

狂风中的少年 提交于 2019-11-27 00:28:28
问题 I am using NLog for logging purpose. My code is as follows: <?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"> <!-- make sure to set 'Copy To Output Directory' option for this file --> <!-- go to http://nlog-project.org/wiki/Configuration_file for more information --> <targets> <target name="logfile" xsi:type="File" layout="${message}" fileName="${basedir}../Data/debugLog1.txt"

Nlog - Generating Header Section for a log file

柔情痞子 提交于 2019-11-26 23:21:57
问题 Just recently got into experimenting with NLog, and it occurs to me that I would like to be able to add header information to the top a log file such as: Executable name File version Release Date Windows User ID etc... After some searching I have been unable to find anything in the existing on-line documentation or code forums which indicates this type of functionality. Is this possible? I have always previously included this sort of information in log files, and have found it useful on

How can I use NLog's RichTextBox Target in WPF application?

此生再无相见时 提交于 2019-11-26 20:46:59
问题 How can I use RichTextBox Target in WPF application? I don't want to have a separate window with log, I want all log messages to be outputted in richTextBox located in WPF dialog. I've tried to use WindowsFormsHost with RichTextBox box inside but that does not worked for me: NLog opened separate Windows Form anyway. 回答1: If you define a RichTextBoxTarget in the config file, a new form is automatically created. This is because NLog initializes before your (named) form and control has been

What is the difference between log4net.ThreadContext and log4net.LogicalThreadContext?

守給你的承諾、 提交于 2019-11-26 19:58:12
问题 UPDATED on 11/18/2014 - While browsing the log4net source repository, I found that the implementation of LogicalThreadContext was modified in November 2011 to that it stores its properties using CallContext.LogicalSetData (and gets them using LogicalGetData). This is important because that means that LogicalThreadContext should now work correctly. Any data stored in LogicalThreadContext should be "flowed" to any child threads or tasks. This compares to ThreadContext (and the old

Why do loggers recommend using a logger per class?

半城伤御伤魂 提交于 2019-11-26 18:55:12
问题 As per NLog's documentation: Most applications will use one logger per class, where the name of the logger is the same as the name of the class. This is the same way that log4net operates. Why is this a good practice? 回答1: With log4net, using one logger per class makes it easy to capture the source of the log message (ie. the class writing to the log). If you don't have one logger per class, but instead have one logger for the entire app, you need to resort to more reflection tricks to know

Nlog Callsite is wrong when wrapper is used

对着背影说爱祢 提交于 2019-11-26 15:49:46
问题 I'm using NLog for logging, I use a wrapper to call log methods, my problem is: if I try to print information about the call site ( ${callsite} ), it prints the wrapper method and not the original method that caused the logger to log. Is there any way to get the original method that called the wrapper method instead? 回答1: See my answer to this question: Problem matching specific NLog logger name I have copied the example code (for an abbreviated NLog wrapper) from that answer here to save

log4net vs. Nlog

点点圈 提交于 2019-11-26 10:58:24
Anyone have experience for both? How do they stack up against each other? We are planning on using one of them for logging in an enterprise application. References: log4net nlog EDIT: We have no existing dependencies to either nlog or log4net. Matt I was recently tasked to "prototype up some loggin'" for an upcoming project. I didn't have any logging framework experience. I researched, ran through tutorials, made toy apps, etc. on Log4Net, NLog, and Enterprise Library for a few days. Came back 3-4 weeks later and put them together into a cohesive demo. Hopefully some of this is useful to you.

log4net vs. Nlog

醉酒当歌 提交于 2019-11-26 02:15:42
问题 Locked . This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions. Anyone have experience for both? How do they stack up against each other? We are planning on using one of them for logging in an enterprise application. References: log4net nlog EDIT: We have no existing dependencies to either nlog or log4net. 回答1: I was recently tasked to "prototype up some loggin'" for an upcoming