title: Get permission denied message when creating a file to /var/log on os x
body: <p>I want to write qt application log to /var/log/message_app.log on OS X. I am getting </p>
  
  <blockquote>
    <p>"Cannot open file for writing:  "Permission denied""</p>
  </blockquote>
  
  <p>message on console. </p>
  
  <p>This is the my test code parts:</p>
  
  <pre><code>logfile = fopen(logFilePath, "a");
    if (!logfile) {
        fprintf(stderr, "ERROR: Unable to access keystroke log file. Please make sure you have the correct permissions.\n");
    }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>      QString filename = "/var/log/data.txt";
        QFile file(filename);
        file.setPermissions(QFile::ExeGroup);
        file.setPermissions(QFile::ExeOther);
        file.setPermissions(QFile::ExeOwner);
        file.setPermissions(QFile::ExeUser);
        if (!file.open(QIODevice::ReadWrite)) {
            qDebug() &lt;&lt; "Cannot open file for writing: " &lt;&lt; file.errorString();
            return 0;
        }
        else {
            QTextStream stream(&amp;file);
            stream &lt;&lt; "something" &lt;&lt; endl;
        }
  </code></pre>
  
  <p>Both of them return same error.</p>
  
  <p>When I start QtCreator from console using sudo command, it works. But when I deployed my app and change some permissions (with chown, chmod, etc.) it doesn't work.</p>
  
  <p>I googled and found out some privileged issues like <a href="https://github.com/mbsanchez/QtPrivilegedHelperExample" rel="nofollow noreferrer">that</a>. </p>
  
  <p>So, is there any other effective solution?</p>
  
  <p>Thanks!</p>