Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
I am getting error from Log
  • Hello there,

    I am getting following error from batch program.

    [2021-03-18 04:00:01] fuelphp.ERROR:
    [PID:20839][Fuel\Tasks\batch::register]chmod() 
    permission denied

    The directory permission is set to 766 and the user have a permission to read/write.

    I gueess the way of initializing logger is maybe wrong.

    So, could you please check it out?

    # How I initialize
    $filename = \Config::get('common.log.dir').DS.date('Y').DS.date('m').DS.'request-log.php';
    \Config::set('log_file', $filename);
    \Config::set('log_threshold', \Fuel::L_INFO);
    \Log::initialize();

    # How I used.
    logger(\Fuel::L_INFO, $something);  

    The strange thing is that this error happens just once a day.
    This error dose not happen second time.

    Do you have any suggetion for this?

    Best regards,
  • HarroHarro
    Accepted Answer
    Under which user does it run? It is usually different from the one the webserver is running.

    chmod operations are only allowed by the file owner, no matter what rights were given. So you can get this error if the file owner is for example httpd, www-data, ....
  • Hello,
    That is right.
    I totally forgot to give the permission to the user that runs batch program.
    Thanks a lot.

  • Hello there,

    I got diffrent error message from file.php like followings.

    [2021-03-25 04:00:01] fuelphp.ERROR: 0 -
    Invalid path:
    "/sys/kernel/security/apparmor/apparmorfs:[11563]/namespaces/",
    directory cannot be read. in /usr/local/batch/fuel/core/classes/file.php
    on line 270 [] [] [1;31mUncaught exception Fuel\Core\InvalidPathException: 0 -
    Invalid path:
    "/sys/kernel/security/apparmor/apparmorfs:[11563]/namespaces/",
    directory cannot be read. in /usr/local/batch/fuel/core/classes/file.php
    on line 270[0m

    This looks like the file path is wrong.
    "/usr/local/batch/fuel/core/classes/file.php

    The correct one should be like this.
    /usr/local/batch/service/fuel/core/classes/file.php

    Do you know why I am getting these errors?

  • Incorrect COREPATH set in index.php ?
  • Maybe what I sahre is insufficinet information.

    I changed log setting in config/config.php as following.

            'log_threshold'   => Fuel::L_ALL,
            //'log_path'        => APPPATH.'logs/',
            'log_path'        => '/var/log/fuel/',
            'log_date_format' => 'Y-m-d H:i:s',
            'log_file'=>'batch.php',

    By the way, this is COREPATH that is defined in index.php.

    define('COREPATH', realpath(__DIR__.'/../fuel/core/').DIRECTORY_SEPARATOR);

    Do you have any idea for this error?
    It dose not happend everytime.
    Just once a day.

    So, I feel like this is strange error.

    Regards,
  • I can't see what your setup is.

    If you have /usr/local/batch/service/fuel/core... and /usr/local/batch/service/public/index.php, then that code is ok. If you moved stuff around, you need to adjust the paths accordingly.

    The fact that you get the wrong path suggests public and fuel are not where are are by default.
  • Hi,

    I will share my setup.

    Possibly, folder structure, public/index.php, bootstrap.php and config/config.php enough?

    I guess I did not move anything.

  • Here is folder structure.

    .git/
    .gitignore
    composer.json
    composer.lock
    fuel/
    oil
    public/
  • I did not modify following.
    public/index.php 


  • Here is config/config.php

    <?php
    /**
     * Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
     *
     * @package    Fuel
     * @version    1.9-dev
     * @author     Fuel Development Team
     * @license    MIT License
     * @copyright  2010 - 2019 Fuel Development Team
     */

    return array(
      /**
       * Localization & internationalization settings
       */
      'language'           => 'ja', // Default language
      //'language_fallback'  => 'ja', // Fallback language when file isn't available for default language
      'locale'             => 'ja_JP.UTF-8', // PHP set_locale() setting, null to not set
      
      /**
       * Internal string encoding charset
       */
      'encoding'  => 'UTF-8',
      
      'default_timezone'   => 'Asia/Tokyo',
      
      'log_threshold'   => Fuel::L_ALL,
      'log_path'        => '/var/log/fuelphp/',
      'log_date_format' => 'Y-m-d H:i:s',
      'log_file'=>'screenshot.php',

      
      'security' => array(
        
        'uri_filter' => array('htmlentities'),
        
        'output_filter' => array('Security::htmlentities'),
        
        'whitelisted_classes' => array(
          'Fuel\\Core\\Presenter',
          'Fuel\\Core\\Response',
          'Fuel\\Core\\View',
          'Fuel\\Core\\ViewModel',
          'Closure',
        ),
      ),
      
      'package_paths' => array(
        PKGPATH,
      ),
    ); 
  • Hello there,

    It looks like it give me an error when if I change root "log_path" to different folder.

    For example, If I keep the log folder to fuel/app/log then it is no problem.

    OK: /var/html/appname/fuel/app/log
    NG: /var/log/fuel/
  • HarroHarro
    Accepted Answer
    That is a different question than you initially asked.

    On modern distro's, you can't just write in any location without the correct security policies in place (apparmor, selinux).  So you need to write a security policy for that.
  • Hi,
    Thanks for that.
    I did not know about that.
    Thank you.
    I will check it out tomorrow morning :)

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion