2

I have an .net core console application for chatting. I have two console app in my solution that names Client and Server. I want to log my activities. And I use nLog library for that. I implemented nlog and nlog.config Nuget Packages from Nuget Package Manager.

This is my NLog.config file;

 <?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:\temp\nlog-internal.log">


<targets>

 <target name="database" xsi:type="Database"
      dbProvider="Npgsql.NpgsqlConnection, Npgsql"
      connectionString="***myPrivateConnectionString***"
         >
  <commandText>
    insert into train_server_logs(
    Application, Logged, Level, Message,
    Logger, CallSite, Exception
    ) values (
    @Application, @Logged, @Level, @Message,
    @Logger, @Callsite, @Exception
    );
  </commandText>

  <parameter name="@application" layout="AspNetCoreNlog" />
  <parameter name="@logged" layout="${date}" />
  <parameter name="@level" layout="${level}" />
  <parameter name="@message" layout="${message}" />
  <parameter name="@logger" layout="${logger}" />
  <parameter name="@callSite" layout="${callsite:filename=true}" />
  <parameter name="@exception" layout="${exception:tostring}" />
  </target>
</targets>

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

And this is my ChatServer project;

 namespace TcpChatServer
  {
    static void Main(string[] args)
      {
                     Logger logger = LogManager.GetLogger("databaseLogger");
                     logger.Info("Server Working!");
      }
  }

And this is my ChatClient project;

 namespace TcpChatClient
  {
    static void Main(string[] args)
      {
                     Logger logger = LogManager.GetLogger("databaseLogger");
                     logger.Info("Client working!");
      }
  }

I am running my solution with multiple startup. And than when I check my database. Server side log was succussfully logged but client side log was not appear.

What is my problem?

Many Thanks!

Mert DEMIRKIRAN
  • 418
  • 5
  • 18
  • Check https://github.com/NLog/NLog/wiki/Logging-troubleshooting and https://github.com/NLog/NLog/wiki/Internal-Logging They will probably give you a hint. – Rolf Kristensen Dec 17 '19 at 16:19

0 Answers0