NLog does not working with Postsharp












0














I found out what the problem is. There is no problem with the code. The problem that I wrote column name incorrect in the query. I do not know how I missed such a thing, but thank you for all your help. You can use the codes for the NLog if you want.



( I trying to Logging with NLog into AOP. I working Winform and using Postsharp. NLog codes into ExceptionLoggingAttribute.cs . This codes studies in Form1.cs but does not working in Aspect. Please Help me! )



AOP inside



namespace LogLibrary
{
[PSerializable]
public class ExceptionLoggingAttribute : OnExceptionAspect
{
public FlowBehavior flowbehavior { get; set; }
public override void OnException(MethodExecutionArgs args)
{
NLog.Logger logger = LogManager.GetLogger("databaseLogger");
logger.Error(args.Exception.Message);
logger.Fatal(args.Exception.Message);
logger.Debug(args.Exception.Message);
logger.Trace(args.Exception.Message);
args.FlowBehavior = FlowBehavior.Continue;
}
}


Nlog.Config İnside



<?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"
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
autoReload="true"
throwExceptions="false"
internalLogLevel="Off" internalLogFile="c:tempnlog-internal.log">


<variable name="myvar" value="myvalue"/>


<targets>

<target name="database" xsi:type="Database"

connectionStringName="NLogConn"

commandText="exec dbo.dlog @username,@ErrorName,@MethodName,@StackName, @Date_Time">

<parameter name="@username" layout="${identity}"/>
<parameter name="@ErrorName" layout="${message}"/>
<parameter name="@MethodName" layout="${machinename}"/>
<parameter name="@StackName" layout="${stacktrace}"/>
<parameter name="@Date_Time" layout="${date}"/>

</target>

</targets>

<rules>
<logger name="databaseLogger" minlevel="Trace" writeTo="database" />
</rules>
</nlog>


App.Config İnside



<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="NLogConn" connectionString="Data Source=DMGM0349997MSSQLSERVER01; Initial Catalog=deneme; Integrated Security=true;" providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>


Form1 inside



using System.Windows.Forms;
using PostSharp.Aspects;
using NLog;
using LogLibrary;


namespace LogApp
{
[ExceptionLogging]
public partial class Form1 : Form
{

public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
throw new Exception("bla bla");
}
}
}


I hope this photo helps you for understand me



https://hizliresim.com/VM0ZDZ










share|improve this question
























  • Is your code entering the aspect code?
    – Amy
    Jul 5 '17 at 15:41










  • Yes, but does not working.
    – SAFAK
    Jul 6 '17 at 6:16










  • please explain "does not work". What are you expecting? What is the current result?
    – Julian
    Jul 6 '17 at 10:50












  • I want to save the error information in the database when the program fails. But this process must be in the aspect
    – SAFAK
    Jul 6 '17 at 11:31










  • Did you verify your internal log : c:tempnlog-internal.log , to see what NLog is trying to do. It is a verbose kind of logging which contains all the information on what NLog is doing. So better have a look at that. It will also record any exceptions that are occurring while NLog tries to log something
    – Sujith
    Jul 7 '17 at 1:35
















0














I found out what the problem is. There is no problem with the code. The problem that I wrote column name incorrect in the query. I do not know how I missed such a thing, but thank you for all your help. You can use the codes for the NLog if you want.



( I trying to Logging with NLog into AOP. I working Winform and using Postsharp. NLog codes into ExceptionLoggingAttribute.cs . This codes studies in Form1.cs but does not working in Aspect. Please Help me! )



AOP inside



namespace LogLibrary
{
[PSerializable]
public class ExceptionLoggingAttribute : OnExceptionAspect
{
public FlowBehavior flowbehavior { get; set; }
public override void OnException(MethodExecutionArgs args)
{
NLog.Logger logger = LogManager.GetLogger("databaseLogger");
logger.Error(args.Exception.Message);
logger.Fatal(args.Exception.Message);
logger.Debug(args.Exception.Message);
logger.Trace(args.Exception.Message);
args.FlowBehavior = FlowBehavior.Continue;
}
}


Nlog.Config İnside



<?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"
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
autoReload="true"
throwExceptions="false"
internalLogLevel="Off" internalLogFile="c:tempnlog-internal.log">


<variable name="myvar" value="myvalue"/>


<targets>

<target name="database" xsi:type="Database"

connectionStringName="NLogConn"

commandText="exec dbo.dlog @username,@ErrorName,@MethodName,@StackName, @Date_Time">

<parameter name="@username" layout="${identity}"/>
<parameter name="@ErrorName" layout="${message}"/>
<parameter name="@MethodName" layout="${machinename}"/>
<parameter name="@StackName" layout="${stacktrace}"/>
<parameter name="@Date_Time" layout="${date}"/>

</target>

</targets>

<rules>
<logger name="databaseLogger" minlevel="Trace" writeTo="database" />
</rules>
</nlog>


App.Config İnside



<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="NLogConn" connectionString="Data Source=DMGM0349997MSSQLSERVER01; Initial Catalog=deneme; Integrated Security=true;" providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>


Form1 inside



using System.Windows.Forms;
using PostSharp.Aspects;
using NLog;
using LogLibrary;


namespace LogApp
{
[ExceptionLogging]
public partial class Form1 : Form
{

public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
throw new Exception("bla bla");
}
}
}


I hope this photo helps you for understand me



https://hizliresim.com/VM0ZDZ










share|improve this question
























  • Is your code entering the aspect code?
    – Amy
    Jul 5 '17 at 15:41










  • Yes, but does not working.
    – SAFAK
    Jul 6 '17 at 6:16










  • please explain "does not work". What are you expecting? What is the current result?
    – Julian
    Jul 6 '17 at 10:50












  • I want to save the error information in the database when the program fails. But this process must be in the aspect
    – SAFAK
    Jul 6 '17 at 11:31










  • Did you verify your internal log : c:tempnlog-internal.log , to see what NLog is trying to do. It is a verbose kind of logging which contains all the information on what NLog is doing. So better have a look at that. It will also record any exceptions that are occurring while NLog tries to log something
    – Sujith
    Jul 7 '17 at 1:35














0












0








0


1





I found out what the problem is. There is no problem with the code. The problem that I wrote column name incorrect in the query. I do not know how I missed such a thing, but thank you for all your help. You can use the codes for the NLog if you want.



( I trying to Logging with NLog into AOP. I working Winform and using Postsharp. NLog codes into ExceptionLoggingAttribute.cs . This codes studies in Form1.cs but does not working in Aspect. Please Help me! )



AOP inside



namespace LogLibrary
{
[PSerializable]
public class ExceptionLoggingAttribute : OnExceptionAspect
{
public FlowBehavior flowbehavior { get; set; }
public override void OnException(MethodExecutionArgs args)
{
NLog.Logger logger = LogManager.GetLogger("databaseLogger");
logger.Error(args.Exception.Message);
logger.Fatal(args.Exception.Message);
logger.Debug(args.Exception.Message);
logger.Trace(args.Exception.Message);
args.FlowBehavior = FlowBehavior.Continue;
}
}


Nlog.Config İnside



<?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"
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
autoReload="true"
throwExceptions="false"
internalLogLevel="Off" internalLogFile="c:tempnlog-internal.log">


<variable name="myvar" value="myvalue"/>


<targets>

<target name="database" xsi:type="Database"

connectionStringName="NLogConn"

commandText="exec dbo.dlog @username,@ErrorName,@MethodName,@StackName, @Date_Time">

<parameter name="@username" layout="${identity}"/>
<parameter name="@ErrorName" layout="${message}"/>
<parameter name="@MethodName" layout="${machinename}"/>
<parameter name="@StackName" layout="${stacktrace}"/>
<parameter name="@Date_Time" layout="${date}"/>

</target>

</targets>

<rules>
<logger name="databaseLogger" minlevel="Trace" writeTo="database" />
</rules>
</nlog>


App.Config İnside



<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="NLogConn" connectionString="Data Source=DMGM0349997MSSQLSERVER01; Initial Catalog=deneme; Integrated Security=true;" providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>


Form1 inside



using System.Windows.Forms;
using PostSharp.Aspects;
using NLog;
using LogLibrary;


namespace LogApp
{
[ExceptionLogging]
public partial class Form1 : Form
{

public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
throw new Exception("bla bla");
}
}
}


I hope this photo helps you for understand me



https://hizliresim.com/VM0ZDZ










share|improve this question















I found out what the problem is. There is no problem with the code. The problem that I wrote column name incorrect in the query. I do not know how I missed such a thing, but thank you for all your help. You can use the codes for the NLog if you want.



( I trying to Logging with NLog into AOP. I working Winform and using Postsharp. NLog codes into ExceptionLoggingAttribute.cs . This codes studies in Form1.cs but does not working in Aspect. Please Help me! )



AOP inside



namespace LogLibrary
{
[PSerializable]
public class ExceptionLoggingAttribute : OnExceptionAspect
{
public FlowBehavior flowbehavior { get; set; }
public override void OnException(MethodExecutionArgs args)
{
NLog.Logger logger = LogManager.GetLogger("databaseLogger");
logger.Error(args.Exception.Message);
logger.Fatal(args.Exception.Message);
logger.Debug(args.Exception.Message);
logger.Trace(args.Exception.Message);
args.FlowBehavior = FlowBehavior.Continue;
}
}


Nlog.Config İnside



<?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"
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
autoReload="true"
throwExceptions="false"
internalLogLevel="Off" internalLogFile="c:tempnlog-internal.log">


<variable name="myvar" value="myvalue"/>


<targets>

<target name="database" xsi:type="Database"

connectionStringName="NLogConn"

commandText="exec dbo.dlog @username,@ErrorName,@MethodName,@StackName, @Date_Time">

<parameter name="@username" layout="${identity}"/>
<parameter name="@ErrorName" layout="${message}"/>
<parameter name="@MethodName" layout="${machinename}"/>
<parameter name="@StackName" layout="${stacktrace}"/>
<parameter name="@Date_Time" layout="${date}"/>

</target>

</targets>

<rules>
<logger name="databaseLogger" minlevel="Trace" writeTo="database" />
</rules>
</nlog>


App.Config İnside



<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="NLogConn" connectionString="Data Source=DMGM0349997MSSQLSERVER01; Initial Catalog=deneme; Integrated Security=true;" providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>


Form1 inside



using System.Windows.Forms;
using PostSharp.Aspects;
using NLog;
using LogLibrary;


namespace LogApp
{
[ExceptionLogging]
public partial class Form1 : Form
{

public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
throw new Exception("bla bla");
}
}
}


I hope this photo helps you for understand me



https://hizliresim.com/VM0ZDZ







c# aop nlog postsharp






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 11 '17 at 6:27

























asked Jul 5 '17 at 14:35









SAFAK

45




45












  • Is your code entering the aspect code?
    – Amy
    Jul 5 '17 at 15:41










  • Yes, but does not working.
    – SAFAK
    Jul 6 '17 at 6:16










  • please explain "does not work". What are you expecting? What is the current result?
    – Julian
    Jul 6 '17 at 10:50












  • I want to save the error information in the database when the program fails. But this process must be in the aspect
    – SAFAK
    Jul 6 '17 at 11:31










  • Did you verify your internal log : c:tempnlog-internal.log , to see what NLog is trying to do. It is a verbose kind of logging which contains all the information on what NLog is doing. So better have a look at that. It will also record any exceptions that are occurring while NLog tries to log something
    – Sujith
    Jul 7 '17 at 1:35


















  • Is your code entering the aspect code?
    – Amy
    Jul 5 '17 at 15:41










  • Yes, but does not working.
    – SAFAK
    Jul 6 '17 at 6:16










  • please explain "does not work". What are you expecting? What is the current result?
    – Julian
    Jul 6 '17 at 10:50












  • I want to save the error information in the database when the program fails. But this process must be in the aspect
    – SAFAK
    Jul 6 '17 at 11:31










  • Did you verify your internal log : c:tempnlog-internal.log , to see what NLog is trying to do. It is a verbose kind of logging which contains all the information on what NLog is doing. So better have a look at that. It will also record any exceptions that are occurring while NLog tries to log something
    – Sujith
    Jul 7 '17 at 1:35
















Is your code entering the aspect code?
– Amy
Jul 5 '17 at 15:41




Is your code entering the aspect code?
– Amy
Jul 5 '17 at 15:41












Yes, but does not working.
– SAFAK
Jul 6 '17 at 6:16




Yes, but does not working.
– SAFAK
Jul 6 '17 at 6:16












please explain "does not work". What are you expecting? What is the current result?
– Julian
Jul 6 '17 at 10:50






please explain "does not work". What are you expecting? What is the current result?
– Julian
Jul 6 '17 at 10:50














I want to save the error information in the database when the program fails. But this process must be in the aspect
– SAFAK
Jul 6 '17 at 11:31




I want to save the error information in the database when the program fails. But this process must be in the aspect
– SAFAK
Jul 6 '17 at 11:31












Did you verify your internal log : c:tempnlog-internal.log , to see what NLog is trying to do. It is a verbose kind of logging which contains all the information on what NLog is doing. So better have a look at that. It will also record any exceptions that are occurring while NLog tries to log something
– Sujith
Jul 7 '17 at 1:35




Did you verify your internal log : c:tempnlog-internal.log , to see what NLog is trying to do. It is a verbose kind of logging which contains all the information on what NLog is doing. So better have a look at that. It will also record any exceptions that are occurring while NLog tries to log something
– Sujith
Jul 7 '17 at 1:35












3 Answers
3






active

oldest

votes


















0














You have to enable first the internal log, set internalLogLevel on "info":



internalLogLevel="Info" internalLogFile="c:tempnlog-internal.log"


If there is still no internalLogFile, then NLog can't find you nlog.config. Check the location of nlog.config.



Alternative you read it config like this:



LogManager.Configuration = new XmlLoggingConfiguration("pathTo_Nlog.config")


Or set-up the config on C#






share|improve this answer





















  • I have nlog.config into my app file but i didn't have nlog-internal.log file. Also NLog works in Form1.cs but not in Aspect codes. (NLog attached Aspect Library)
    – SAFAK
    Jul 7 '17 at 11:57










  • I hope this photo helps you for understand me hizliresim.com/VM0ZDZ
    – SAFAK
    Jul 10 '17 at 6:56










  • I found out what the problem is. Thank you
    – SAFAK
    Jul 11 '17 at 6:29



















0














I hope this photo helps you for understand me



enter image description here






share|improve this answer























  • Please edit your question instead of giving information in an answer
    – Julian
    Jul 10 '17 at 9:50










  • I do. thank you for information
    – SAFAK
    Jul 10 '17 at 10:41










  • Thank you for edit but i do not have the able to embed images yet. It gives this message : As soon as you earn 10 reputation on the site, you'll be able to embed images.
    – SAFAK
    Jul 10 '17 at 12:01





















0














I had the same problem. When I executed my C# console app's main method that contained codes below, does not any log created:



private static readonly ILog Log = LogManager.GetLogger<Program>();

Log.Info("Application Started . . .");


My problem was the location of NLog.config file.



I right clicked and selected Properties NLog.config in Visual Studio. Then for "Copy to Output Directory" property, selected "Copy if newer" option.



The problem was that NLog.config file was not in executing directory of my app.



This page describes how to configure NLog via XML specification.
specially read the Log Location section.



My AppConfig :



<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging"/>
</sectionGroup>
<common>
<logging>
<factoryAdapter type="Common.Logging.NLog.NLogLoggerFactoryAdapter, Common.Logging.NLog444">
<arg key="configType" value="INLINE"/>
</factoryAdapter>
</logging>
</common>


and NLog.config files :



<?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"
internalLogLevel="Trace" internalLogFile="d:NLog_Internallog.txt">
<variable name="logDirectory" value="logs" />
<targets>
<target xsi:type="File"
name="fileXmlName"
header="&lt;nlog&gt;"
footer="&lt;/nlog&gt;"
fileName="${logDirectory}/${shortdate}.log.xml"
concurrentWrites="true"
createDirs="true"
autoFlush="true">
<layout xsi:type="Log4JXmlEventLayout">
</layout>
</target>
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo="fileXmlName" />
</rules>
</nlog>





share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f44929211%2fnlog-does-not-working-with-postsharp%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    You have to enable first the internal log, set internalLogLevel on "info":



    internalLogLevel="Info" internalLogFile="c:tempnlog-internal.log"


    If there is still no internalLogFile, then NLog can't find you nlog.config. Check the location of nlog.config.



    Alternative you read it config like this:



    LogManager.Configuration = new XmlLoggingConfiguration("pathTo_Nlog.config")


    Or set-up the config on C#






    share|improve this answer





















    • I have nlog.config into my app file but i didn't have nlog-internal.log file. Also NLog works in Form1.cs but not in Aspect codes. (NLog attached Aspect Library)
      – SAFAK
      Jul 7 '17 at 11:57










    • I hope this photo helps you for understand me hizliresim.com/VM0ZDZ
      – SAFAK
      Jul 10 '17 at 6:56










    • I found out what the problem is. Thank you
      – SAFAK
      Jul 11 '17 at 6:29
















    0














    You have to enable first the internal log, set internalLogLevel on "info":



    internalLogLevel="Info" internalLogFile="c:tempnlog-internal.log"


    If there is still no internalLogFile, then NLog can't find you nlog.config. Check the location of nlog.config.



    Alternative you read it config like this:



    LogManager.Configuration = new XmlLoggingConfiguration("pathTo_Nlog.config")


    Or set-up the config on C#






    share|improve this answer





















    • I have nlog.config into my app file but i didn't have nlog-internal.log file. Also NLog works in Form1.cs but not in Aspect codes. (NLog attached Aspect Library)
      – SAFAK
      Jul 7 '17 at 11:57










    • I hope this photo helps you for understand me hizliresim.com/VM0ZDZ
      – SAFAK
      Jul 10 '17 at 6:56










    • I found out what the problem is. Thank you
      – SAFAK
      Jul 11 '17 at 6:29














    0












    0








    0






    You have to enable first the internal log, set internalLogLevel on "info":



    internalLogLevel="Info" internalLogFile="c:tempnlog-internal.log"


    If there is still no internalLogFile, then NLog can't find you nlog.config. Check the location of nlog.config.



    Alternative you read it config like this:



    LogManager.Configuration = new XmlLoggingConfiguration("pathTo_Nlog.config")


    Or set-up the config on C#






    share|improve this answer












    You have to enable first the internal log, set internalLogLevel on "info":



    internalLogLevel="Info" internalLogFile="c:tempnlog-internal.log"


    If there is still no internalLogFile, then NLog can't find you nlog.config. Check the location of nlog.config.



    Alternative you read it config like this:



    LogManager.Configuration = new XmlLoggingConfiguration("pathTo_Nlog.config")


    Or set-up the config on C#







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Jul 7 '17 at 10:56









    Julian

    11.9k75086




    11.9k75086












    • I have nlog.config into my app file but i didn't have nlog-internal.log file. Also NLog works in Form1.cs but not in Aspect codes. (NLog attached Aspect Library)
      – SAFAK
      Jul 7 '17 at 11:57










    • I hope this photo helps you for understand me hizliresim.com/VM0ZDZ
      – SAFAK
      Jul 10 '17 at 6:56










    • I found out what the problem is. Thank you
      – SAFAK
      Jul 11 '17 at 6:29


















    • I have nlog.config into my app file but i didn't have nlog-internal.log file. Also NLog works in Form1.cs but not in Aspect codes. (NLog attached Aspect Library)
      – SAFAK
      Jul 7 '17 at 11:57










    • I hope this photo helps you for understand me hizliresim.com/VM0ZDZ
      – SAFAK
      Jul 10 '17 at 6:56










    • I found out what the problem is. Thank you
      – SAFAK
      Jul 11 '17 at 6:29
















    I have nlog.config into my app file but i didn't have nlog-internal.log file. Also NLog works in Form1.cs but not in Aspect codes. (NLog attached Aspect Library)
    – SAFAK
    Jul 7 '17 at 11:57




    I have nlog.config into my app file but i didn't have nlog-internal.log file. Also NLog works in Form1.cs but not in Aspect codes. (NLog attached Aspect Library)
    – SAFAK
    Jul 7 '17 at 11:57












    I hope this photo helps you for understand me hizliresim.com/VM0ZDZ
    – SAFAK
    Jul 10 '17 at 6:56




    I hope this photo helps you for understand me hizliresim.com/VM0ZDZ
    – SAFAK
    Jul 10 '17 at 6:56












    I found out what the problem is. Thank you
    – SAFAK
    Jul 11 '17 at 6:29




    I found out what the problem is. Thank you
    – SAFAK
    Jul 11 '17 at 6:29













    0














    I hope this photo helps you for understand me



    enter image description here






    share|improve this answer























    • Please edit your question instead of giving information in an answer
      – Julian
      Jul 10 '17 at 9:50










    • I do. thank you for information
      – SAFAK
      Jul 10 '17 at 10:41










    • Thank you for edit but i do not have the able to embed images yet. It gives this message : As soon as you earn 10 reputation on the site, you'll be able to embed images.
      – SAFAK
      Jul 10 '17 at 12:01


















    0














    I hope this photo helps you for understand me



    enter image description here






    share|improve this answer























    • Please edit your question instead of giving information in an answer
      – Julian
      Jul 10 '17 at 9:50










    • I do. thank you for information
      – SAFAK
      Jul 10 '17 at 10:41










    • Thank you for edit but i do not have the able to embed images yet. It gives this message : As soon as you earn 10 reputation on the site, you'll be able to embed images.
      – SAFAK
      Jul 10 '17 at 12:01
















    0












    0








    0






    I hope this photo helps you for understand me



    enter image description here






    share|improve this answer














    I hope this photo helps you for understand me



    enter image description here







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Jul 10 '17 at 11:41









    JP Hellemons

    4,294643100




    4,294643100










    answered Jul 7 '17 at 12:35









    SAFAK

    45




    45












    • Please edit your question instead of giving information in an answer
      – Julian
      Jul 10 '17 at 9:50










    • I do. thank you for information
      – SAFAK
      Jul 10 '17 at 10:41










    • Thank you for edit but i do not have the able to embed images yet. It gives this message : As soon as you earn 10 reputation on the site, you'll be able to embed images.
      – SAFAK
      Jul 10 '17 at 12:01




















    • Please edit your question instead of giving information in an answer
      – Julian
      Jul 10 '17 at 9:50










    • I do. thank you for information
      – SAFAK
      Jul 10 '17 at 10:41










    • Thank you for edit but i do not have the able to embed images yet. It gives this message : As soon as you earn 10 reputation on the site, you'll be able to embed images.
      – SAFAK
      Jul 10 '17 at 12:01


















    Please edit your question instead of giving information in an answer
    – Julian
    Jul 10 '17 at 9:50




    Please edit your question instead of giving information in an answer
    – Julian
    Jul 10 '17 at 9:50












    I do. thank you for information
    – SAFAK
    Jul 10 '17 at 10:41




    I do. thank you for information
    – SAFAK
    Jul 10 '17 at 10:41












    Thank you for edit but i do not have the able to embed images yet. It gives this message : As soon as you earn 10 reputation on the site, you'll be able to embed images.
    – SAFAK
    Jul 10 '17 at 12:01






    Thank you for edit but i do not have the able to embed images yet. It gives this message : As soon as you earn 10 reputation on the site, you'll be able to embed images.
    – SAFAK
    Jul 10 '17 at 12:01













    0














    I had the same problem. When I executed my C# console app's main method that contained codes below, does not any log created:



    private static readonly ILog Log = LogManager.GetLogger<Program>();

    Log.Info("Application Started . . .");


    My problem was the location of NLog.config file.



    I right clicked and selected Properties NLog.config in Visual Studio. Then for "Copy to Output Directory" property, selected "Copy if newer" option.



    The problem was that NLog.config file was not in executing directory of my app.



    This page describes how to configure NLog via XML specification.
    specially read the Log Location section.



    My AppConfig :



    <sectionGroup name="common">
    <section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging"/>
    </sectionGroup>
    <common>
    <logging>
    <factoryAdapter type="Common.Logging.NLog.NLogLoggerFactoryAdapter, Common.Logging.NLog444">
    <arg key="configType" value="INLINE"/>
    </factoryAdapter>
    </logging>
    </common>


    and NLog.config files :



    <?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"
    internalLogLevel="Trace" internalLogFile="d:NLog_Internallog.txt">
    <variable name="logDirectory" value="logs" />
    <targets>
    <target xsi:type="File"
    name="fileXmlName"
    header="&lt;nlog&gt;"
    footer="&lt;/nlog&gt;"
    fileName="${logDirectory}/${shortdate}.log.xml"
    concurrentWrites="true"
    createDirs="true"
    autoFlush="true">
    <layout xsi:type="Log4JXmlEventLayout">
    </layout>
    </target>
    </targets>
    <rules>
    <logger name="*" minlevel="Trace" writeTo="fileXmlName" />
    </rules>
    </nlog>





    share|improve this answer


























      0














      I had the same problem. When I executed my C# console app's main method that contained codes below, does not any log created:



      private static readonly ILog Log = LogManager.GetLogger<Program>();

      Log.Info("Application Started . . .");


      My problem was the location of NLog.config file.



      I right clicked and selected Properties NLog.config in Visual Studio. Then for "Copy to Output Directory" property, selected "Copy if newer" option.



      The problem was that NLog.config file was not in executing directory of my app.



      This page describes how to configure NLog via XML specification.
      specially read the Log Location section.



      My AppConfig :



      <sectionGroup name="common">
      <section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging"/>
      </sectionGroup>
      <common>
      <logging>
      <factoryAdapter type="Common.Logging.NLog.NLogLoggerFactoryAdapter, Common.Logging.NLog444">
      <arg key="configType" value="INLINE"/>
      </factoryAdapter>
      </logging>
      </common>


      and NLog.config files :



      <?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"
      internalLogLevel="Trace" internalLogFile="d:NLog_Internallog.txt">
      <variable name="logDirectory" value="logs" />
      <targets>
      <target xsi:type="File"
      name="fileXmlName"
      header="&lt;nlog&gt;"
      footer="&lt;/nlog&gt;"
      fileName="${logDirectory}/${shortdate}.log.xml"
      concurrentWrites="true"
      createDirs="true"
      autoFlush="true">
      <layout xsi:type="Log4JXmlEventLayout">
      </layout>
      </target>
      </targets>
      <rules>
      <logger name="*" minlevel="Trace" writeTo="fileXmlName" />
      </rules>
      </nlog>





      share|improve this answer
























        0












        0








        0






        I had the same problem. When I executed my C# console app's main method that contained codes below, does not any log created:



        private static readonly ILog Log = LogManager.GetLogger<Program>();

        Log.Info("Application Started . . .");


        My problem was the location of NLog.config file.



        I right clicked and selected Properties NLog.config in Visual Studio. Then for "Copy to Output Directory" property, selected "Copy if newer" option.



        The problem was that NLog.config file was not in executing directory of my app.



        This page describes how to configure NLog via XML specification.
        specially read the Log Location section.



        My AppConfig :



        <sectionGroup name="common">
        <section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging"/>
        </sectionGroup>
        <common>
        <logging>
        <factoryAdapter type="Common.Logging.NLog.NLogLoggerFactoryAdapter, Common.Logging.NLog444">
        <arg key="configType" value="INLINE"/>
        </factoryAdapter>
        </logging>
        </common>


        and NLog.config files :



        <?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"
        internalLogLevel="Trace" internalLogFile="d:NLog_Internallog.txt">
        <variable name="logDirectory" value="logs" />
        <targets>
        <target xsi:type="File"
        name="fileXmlName"
        header="&lt;nlog&gt;"
        footer="&lt;/nlog&gt;"
        fileName="${logDirectory}/${shortdate}.log.xml"
        concurrentWrites="true"
        createDirs="true"
        autoFlush="true">
        <layout xsi:type="Log4JXmlEventLayout">
        </layout>
        </target>
        </targets>
        <rules>
        <logger name="*" minlevel="Trace" writeTo="fileXmlName" />
        </rules>
        </nlog>





        share|improve this answer












        I had the same problem. When I executed my C# console app's main method that contained codes below, does not any log created:



        private static readonly ILog Log = LogManager.GetLogger<Program>();

        Log.Info("Application Started . . .");


        My problem was the location of NLog.config file.



        I right clicked and selected Properties NLog.config in Visual Studio. Then for "Copy to Output Directory" property, selected "Copy if newer" option.



        The problem was that NLog.config file was not in executing directory of my app.



        This page describes how to configure NLog via XML specification.
        specially read the Log Location section.



        My AppConfig :



        <sectionGroup name="common">
        <section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging"/>
        </sectionGroup>
        <common>
        <logging>
        <factoryAdapter type="Common.Logging.NLog.NLogLoggerFactoryAdapter, Common.Logging.NLog444">
        <arg key="configType" value="INLINE"/>
        </factoryAdapter>
        </logging>
        </common>


        and NLog.config files :



        <?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"
        internalLogLevel="Trace" internalLogFile="d:NLog_Internallog.txt">
        <variable name="logDirectory" value="logs" />
        <targets>
        <target xsi:type="File"
        name="fileXmlName"
        header="&lt;nlog&gt;"
        footer="&lt;/nlog&gt;"
        fileName="${logDirectory}/${shortdate}.log.xml"
        concurrentWrites="true"
        createDirs="true"
        autoFlush="true">
        <layout xsi:type="Log4JXmlEventLayout">
        </layout>
        </target>
        </targets>
        <rules>
        <logger name="*" minlevel="Trace" writeTo="fileXmlName" />
        </rules>
        </nlog>






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 19 '18 at 13:11









        Javad

        369




        369






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f44929211%2fnlog-does-not-working-with-postsharp%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Can a sorcerer learn a 5th-level spell early by creating spell slots using the Font of Magic feature?

            ts Property 'filter' does not exist on type '{}'

            mat-slide-toggle shouldn't change it's state when I click cancel in confirmation window