title: log4net: Where to place static LogManger object? (using it in different projects of a solution, each having an individual config-file)
body: <p>So far I did not get in touch with config-files. So, relating to that, I think I miss some basic knowledge to completely understand, when using log4net the first time.</p>
  
  <hr>
  
  <p>This is what I already read:</p>
  
  <p><a href="https://stackify.com/log4net-guide-dotnet-logging" rel="nofollow noreferrer">https://stackify.com/log4net-guide-dotnet-logging</a></p>
  
  <p><a href="https://csharp.today/log4net-tutorial-great-library-for-logging" rel="nofollow noreferrer">https://csharp.today/log4net-tutorial-great-library-for-logging</a></p>
  
  <p><a href="https://stackoverflow.com/questions/648813/log4net-configuration-with-assembly">log4net configuration with [assembly:]</a></p>
  
  <hr>
  
  <p>Lets say we got three different types of projects in a solution, each having log4net attached:</p>
  
  <ul>
  <li>Project MidLevel: .NET Framework 4.6.1 (using LowLevel)</li>
  <li>Project LowLevel: .NET Standard 2.0 </li>
  <li>Project Application: .NET Framework 4.6.1 (using LowLevel and MidLevel)</li>
  </ul>
  
  <p>1) Where exactly shall I place the following lines? In each class where I want to log?</p>
  
  <pre><code>private static readonly log4net.ILog log 
         = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
  </code></pre>
  
  <p>2) I wondered how I get static object above everywhere where I want to use it. So I added a class like the following into project LowLevel, hoping just a 'using' could help.</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Text;
  
  using log4net;
  
  namespace LowLevel.NuGet.Log4Net
  {
      public class Log4Net
      {
          // Avoiding overhead by logging, reducing use of CPU via static LogManager object.
          private static readonly log4net.ILog _log
              = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
  
          //
          // Properties
          //
  
          public static log4net.ILog Log { get =&gt; _log; }
      }
  }
  </code></pre>
  
  <p>But I suggest I wont work, because a .NET Standard 2.0 project hasn't got its own config-file.</p>
  
  <ul>
  <li>Am I am right? (Of course I will check this on my own, too. But it might be helpful if you point me in advance, to knowledge I am missing at the moment.)</li>
  <li>How is it possible to create just one static LogManager object, using it in every project? </li>
  <li>Will mentioned static LogManger object use different config-files of each individual project then? And if not, how to achieve this?</li>
  </ul>
  
  <p>Many thanks in advance.</p>