title: nginx logs for location
body: <p>Need some help in setting up nginx logs so that they are not duplicated. </p>
  
  <p>My configuration is as following. What I would like to achieve is that all logs for say, <a href="http://example.com/app" rel="noreferrer">http://example.com/app</a> goes to file app.access.log and logs for rest of the site goes to file main.access.log</p>
  
  <p>However, following configuration logs app logs to both, app.access.log and main.access.log.</p>
  
  <pre><code>server {
  
         access_log /var/log/nginx/main.access.log;
  
  
         location /app {
             access_log /var/log/nginx/app.access.log;
         }
  }
  </code></pre>
  
  <p>Any idea how to fix this? </p>