Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does NLog raise an event when something is logged?

Tags:

c#

logging

nlog

I want to be able to catch this event in order to not only log the message but to insert this message into a ListView simultaneously. Is there such an event?

like image 762
Pete Hilde Avatar asked Apr 05 '18 11:04

Pete Hilde


People also ask

Is NLog asynchronous?

NLog 1.0 supports asynchronous logging, but there is no good support for asynchronous exception handling. This is because wrappers targets are not capable of receiving exceptions which are raised on other threads.

Where are NLog logs stored?

By default, the web. nlog file can be found at: C:\Program Files (x86)\Pleasant Solutions\Pleasant Password Server\www\web. nlog.

Which of the following logging levels does NLog support?

NLog supports semantic/structured logging known from similar frameworks like Serilog and Microsoft. Extensions. Logging. With structured logging, you no longer log just simple text messages.

What is NLog logger?

NLog is “a free logging platform for . NET, Silverlight and Windows Phone with rich log routing and management capabilities. It makes it easy to produce and manage high-quality logs for your application regardless of its size or complexity.”


1 Answers

The comments are right, but to elaborate:

In NLog log-events aren't event-driven (there are no event handlers), but route-driven. So every event is matched to the defined routes (the <rules> in your nlog.config).

With the routes you can send the log-events so 0, 1 or multiple targets and create fallbacks, filtering etc.

So if you need the logevents in a ListView, you need to search for a target to use or write a custom one.

Full list of targets are here: https://nlog-project.org/config/?tab=targets

Writing a custom target is explained here: https://github.com/NLog/NLog/wiki/How-to-write-a-custom-target

Happy logging :)

like image 188
Julian Avatar answered Nov 07 '22 10:11

Julian