I am implementing logging in my app via NLog. This 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/XMLSchema-instance">
<targets async="true">
<target xsi:type="File"
name="ExceptionTarget"
fileName="LOG.txt"
layout="${date:format=dd MMM yyyy HH-mm-ss} ${uppercase:${level}} ${newline}${message} ${exception::maxInnerExceptionLevel=5:format=ToString}${newline}${stacktrace}${newline}"/>
</targets>
<targets async="true">
<target xsi:type="File"
name="InfoTarget"
fileName="LOG.txt"
layout="${date:format=mm-ss} ${uppercase:${level}} ${newline}${message} ${newline}"/>
</targets>
<rules>
<logger name="*" level="Error" writeTo="ExceptionTarget"/>
<logger name="*" level="Info" writeTo="InfoTarget"/>
</rules>
</nlog>
When I deploy the app out with ClickOnce, no log.txt file is being created. No errors occur, and my app runs as normal, but nothing is happening.
How to solve this problem?
Create a Console Application project in Visual Studio. Install NLog and its dependencies. Create and configure the NLog logger. Integrate the logger into the C# Console Application.
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.
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.”
nlog file can be found at: C:\Program Files (x86)\Pleasant Solutions\Pleasant Password Server\www\web. nlog.
The ClickOnce installer is not deploying the NLog.config file when the software is installed, so your app do not have any logging configuration.
Solution:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With