title: Pass command-line arguments to Startup class in ASP.NET Core
body: <p>I have arguments passed in via the command-line</p>
  <pre><code>private static int Main(string[] args)
  {
      const string PORT = &quot;12345&quot;    ;
  
      var listeningUrl = $&quot;http://localhost:{PORT}&quot;;
  
      var builder = new WebHostBuilder()
          .UseStartup&lt;Startup&gt;()
          .UseKestrel()
          .UseUrls(listeningUrl);
  
      var host = builder.Build();
      WriteLine($&quot;Running on {PORT}&quot;);
      host.Run();
  
      return 0;
  }
  </code></pre>
  <p>One of these arguments is a logging output directory. How do I get this value into my <code>Startup</code> class so I can write out to this directory when I receive a request?</p>
  <p>I'd like to avoid using a static class. Would a service that supplies the value be the right way?  If so, how do I get services injected into my middleware?</p>