nlog

NLog per session

Is there any way to configure NLog to log information per application session? As of now it appends the messages in the log file each time application is executed (WinForm). What we'd like to have is to only store the info of the current session. Meaning that when application launches, all previous messages are cleared before any new mes...

How to add target of Nlog to a specific textbox control, so the log messages will be shown in that control.

I have used following config of NLog to add the log text to control of specified Name on specified form. <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt; <targets> <target name="control" xsi:type="FormControl" append="true" controlName="textB...

How to add a listener in NLog using Code

Consider NLog is already configured and logging messages to a file, I want to add a listener that will be called each time a message is logged. I read the documentation on NLog but what it says in document doesn't work. Does anyone know how to add a listener using Code in NLog. Thanks ...

Using NLog as a rollover file logger

How - if possible - can I use NLog as a rollover file logger? as if: I want to have at most 31 files for 31 days and when a new day started, if there is an old day log file ##.log, then it should be deleted but during that day all logs are appended and will be there at least for 27 days. ...

Nlog .. 2 questions .. singleton and calling class/method/thread

Hi .. just trying to get up to speed fast. 2 questions .. My intention was to have a singleton class to make NLog available to the whole application .. is this the correct approach. How do I record the source i.e. Class .. Method .. thread etc. of the entry in the log. ...

NLog Database Target Not Finding Table

I am using NLog 1.0 and have the following configuration file: <?xml version="1.0"?> <nlog autoReload="true" throwExceptions="true"> <targets> <!--<target name="console" xsi:type="ColoredConsole" layout="${date:format=HH\:mm\:ss}|${level}|${stacktrace}|${message}" /> <target name="file" xsi:type="File" fileName="${base...

Logging in asp.net mvc application

Hi every one! I'm writing an application in asp.net mvc. I have got presentation layer, controllers and viewModel layer, document layer ( document model [I use ravendb] and repositories) and a framework layer. Currently I'm wondering how to design logging. I have chosen Nlog + Ninject.Logging extensions. My question is what informatio...

Why do loggers recommend using a logger per class?

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? ...

nlog with Growl for Windows target

I am trying to use the target which can be found http://ryanfarley.com/blog/archive/2010/05/06/announcing-the-growl-for-windows-target-for-nlog.aspx. I have the nlog framework working as before I add the config lines for growl all works fine. The config file is <?xml version="1.0" encoding="utf-8" ?> <nlog xmlns="http://www.nlog-proje...

NLog - DDL for Log Table and Setting the ConnectionString Programmatically

1: Is there a create statement for the Database Target Log Table for all the possible fields documented somewhere? I created one by guessing and I could check the source, but it would be handy if the generic SQL was available. I searched StackOverflow and the NLog site, but the SQL I found was dated and contained incorrect field types....

NLog: can't write to event log

I can't write to the event log with NLog. I've been able to write to the console and to a file. I've turned on exceptions in NLog and am receiving no feedback from NLog. Here is my 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/XM...

Is there any way to do a conditional in a NLog layout?

I'm trying to create a NLog layout config like so: layout = "${callsite} > ${message} (${exception:format=tostring})" The output for this layout is (when I test it): TestProject.Program.Main > exception thrown (System.Exception: exception message) However, if I try to output a message that doesn't have an exception, it shows up ...

Suggestions for hosted log server?

I'm looking for recommendations for a hosted service to collect logging information from client applications. The service would preferably be a high-availability service using a cloud infrastructure or something equivalent. I'd like to be able to direct some logging information from my .NET client application (using a logging framework ...

How to log to multiple targets using NLog?

I am using NLog and I want to log to RichTextBox and File at the same time. And I want to configure the Logger programmatically, not with xml config file. The following code only logs to the last target (File in this case). Can anybody help? RichTextBoxTarget t1 = new RichTextBoxTarget(); t1.Layout = "${date} ${message}"; t1.ControlNam...

ASP.NET MVC2 + Ninject + NLog (+ shared hosting?) = NullReferenceException

I have an MVC2 app that's based on the Tekpub Starter Site, so it uses Ninject for dependency injection, NLog for logging, and a bunch of other libraries in various places. As far as I can tell though, it's these that are causing my problem. Everything works beautifully on my PC using the ASP.NET dev server (Cassini) but when I deploy ...

Dependency injection and named loggers

I am interested in learning more about how people inject logging with dependency injection platforms. Although the links below and my examples refer to log4net and Unity, I am not necessarily going to use either of those. For dependency injection/IOC, I will probably use MEF as that is the standard that the rest of the project (large) ...

Configuring NLog to log exceptions in an XML output?

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="$...

Security Exceptions while initializing Nlog event log target

Hi all, I'm using NLog in my ASP.NET application hosted on IIS and Windows server 2003. When I run the code on my develop machine, everything is Okay. But when I deployed the code to the server. The initialization of NLog target will cause an security exception: Security Exception Description: The application attempted to perform an o...

Add / remove logfiles during runtime in NLog

Hi, 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 simil...

How to configure a default target in NLog

I am trying to convert existing logging library used by a bunch of apps to use NLog. The existing logging code has no indirection, logging calls go straight from the caller to a webservice call. The existing logging code is implemented as a static singleton. I need to do this in such a way that existing applications that use this libr...