We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 50722
    • 35 Posts
    Hi all,

    Firstly here's my setup:

    MAMP localhost on OSX 10.9.5
    modx 2.5.4
    php 5.6.2
    mysql 5.5.38

    I'm trying to demonstrate Error Log to a couple of devs but can't get obvious errors to record. Here's what i've done so far:
    - removed commas/semi-colons from Wayfinder and If respectively
    - cleared cache (just to be safe even though this auto-cleared on save)

    Both of these predictably caused the site not to preview, however they didn't show anything in Error Log.

    In
    ./connectors/modx.config.js.php
    i've added the following to try and force logs with no joy:

    $modx->log(modX::LOG_LEVEL_ERROR, '[Wayfinder] IAN: LOG_LEVEL_ERROR');
    $modx->log(modX::LOG_LEVEL_DEBUG, '[Wayfinder] IAN: LOG_LEVEL_DEBUG'.print_r($scriptProperties,true));
    $modx->log(modX::LOG_LEVEL_ERROR,’Testing: ’ . $resourceId);
    


    The only Error Log i am getting - which i assume is totally unrelated esp as it was a few weeks back - is this:
    [2015-06-24 17:18:03] (ERROR @ /modx/modx-sample-site/connectors/modx.config.js.php) Error caching lexicon topic lexicon/en/core/resource
    


    The following, logged as the same date as the sole error log, is from ./core.cache/logs/install.config.2015-06-24T15.20.26.log and looks related to setup:
    [2015-06-24 15:20:29] (ERROR @ /modx/tech-team-demo/setup/index.php) Could not copy /Applications/MAMP/htdocs/modx/tech-team-demo/core/packages/core/modContext/1c656b9d6b7f6cc759a43625a9b5b06b/0/ to /Applications/MAMP/htdocs/modx/tech-team-demo/index.php
    [2015-06-24 15:20:29] (ERROR @ /modx/tech-team-demo/setup/index.php) Could not copy /Applications/MAMP/htdocs/modx/tech-team-demo/core/packages/core/modContext/1c656b9d6b7f6cc759a43625a9b5b06b/1/ to /Applications/MAMP/htdocs/modx/tech-team-demo/ht.access
    [2015-06-24 15:20:29] (ERROR @ /modx/tech-team-demo/setup/index.php) Could not copy /Applications/MAMP/htdocs/modx/tech-team-demo/core/packages/core/modContext/ff6120c493ce56e74d608289a9d3493d/0/ to /Applications/MAMP/htdocs/modx/tech-team-demo/manager/assets
    [2015-06-24 15:20:29] (ERROR @ /modx/tech-team-demo/setup/index.php) Could not copy /Applications/MAMP/htdocs/modx/tech-team-demo/core/packages/core/modContext/ff6120c493ce56e74d608289a9d3493d/1/ to /Applications/MAMP/htdocs/modx/tech-team-demo/manager/controllers
    [2015-06-24 15:20:29] (ERROR @ /modx/tech-team-demo/setup/index.php) Could not copy /Applications/MAMP/htdocs/modx/tech-team-demo/core/packages/core/modContext/ff6120c493ce56e74d608289a9d3493d/2/ to /Applications/MAMP/htdocs/modx/tech-team-demo/manager/templates
    [2015-06-24 15:20:29] (ERROR @ /modx/tech-team-demo/setup/index.php) Could not copy /Applications/MAMP/htdocs/modx/tech-team-demo/core/packages/core/modContext/ff6120c493ce56e74d608289a9d3493d/3/ to /Applications/MAMP/htdocs/modx/tech-team-demo/manager/min
    [2015-06-24 15:20:29] (ERROR @ /modx/tech-team-demo/setup/index.php) Could not copy /Applications/MAMP/htdocs/modx/tech-team-demo/core/packages/core/modContext/ff6120c493ce56e74d608289a9d3493d/4/ to /Applications/MAMP/htdocs/modx/tech-team-demo/manager/ht.access
    [2015-06-24 15:20:29] (ERROR @ /modx/tech-team-demo/setup/index.php) Could not copy /Applications/MAMP/htdocs/modx/tech-team-demo/core/packages/core/modContext/ff6120c493ce56e74d608289a9d3493d/5/ to /Applications/MAMP/htdocs/modx/tech-team-demo/manager/cache.manifest.php
    [2015-06-24 15:20:29] (ERROR @ /modx/tech-team-demo/setup/index.php) Could not copy /Applications/MAMP/htdocs/modx/tech-team-demo/core/packages/core/modContext/ff6120c493ce56e74d608289a9d3493d/6/ to /Applications/MAMP/htdocs/modx/tech-team-demo/manager/index.php
    [2015-06-24 15:20:29] (ERROR @ /modx/tech-team-demo/setup/index.php) Could not install files from /Applications/MAMP/htdocs/modx/tech-team-demo/core/packages/core/xPDOFileVehicle/e2e0c23aab7d2a040e65228923bf8b9d/ to /Applications/MAMP/htdocs/modx/tech-team-demo/connectors/
    [2015-06-24 15:20:29] (ERROR @ /modx/tech-team-demo/setup/index.php) Could not install files from /Applications/MAMP/htdocs/modx/tech-team-demo/core/packages/core/xPDOFileVehicle/04a5da60703f5f41be1da601c1dca692/ to /Applications/MAMP/htdocs/modx/tech-team-demo/connectors/
    [2015-06-24 15:20:29] (ERROR @ /modx/tech-team-demo/setup/index.php) Could not install files from /Applications/MAMP/htdocs/modx/tech-team-demo/core/packages/core/xPDOFileVehicle/2259bb7a4252c78e448d9eaab398079b/ to /Applications/MAMP/htdocs/modx/tech-team-demo/connectors/
    [2015-06-24 15:20:29] (ERROR @ /modx/tech-team-demo/setup/index.php) Could not install files from /Applications/MAMP/htdocs/modx/tech-team-demo/core/packages/core/xPDOFileVehicle/f5434a3338faf93fc8ac71649bc4eaec/ to /Applications/MAMP/htdocs/modx/tech-team-demo/connectors/
    


    Thanks in advance!

    This question has been answered by multiple community members. See the first response.

    [ed. note: powellian last edited this post 8 years, 9 months ago.]
      • 50722
      • 35 Posts
      Just a thought/idea - as i'm running this in localhost could there be read/write issues that OSX won't let me alter? for example:
      I wasn’t able to rename ht.access to .htaccess to enable friendly url’s, so maybe this mac is being a bit draconian.

      That's just a stab, but i have admin rights on this mac so could address it if that's the issue
      • discuss.answer
        Your formatted text is inside code tags.

        By default, MODX is set to a log_level of 1 (ERROR) in the System Settings. If you want different levels, set it to 2 (WARN), 3 (INFO), or 4 (DEBUG). It's cumulative, so if you set it to 4 it will log all of them.

        $modx->log(modX::LOG_LEVEL_ERROR, '[mySnippet] missing the &xyz property!');

        http://rtfm.modx.com/revolution/2.x/developing-in-modx/basic-development/snippets/how-to-write-a-good-snippet#HowtoWriteaGoodSnippet-LogErrorsandInfo
          Studying MODX in the desert - http://sottwell.com
          Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
          Join the Slack Community - http://modx.org
          • 50722
          • 35 Posts
          Yep, spotted that formatting glitch.

          Many thanks for your quick reply. I set the system log level t 4 and the errors showed instantly, so perfect.
          I'm looking at the good snippet writing rtfm info and am going to experiment with customising the error messages.

          Thanks again
            • 3749
            • 24,544 Posts
            You can do something like this in your code:

            $modx->setLogLevel(modX::LOG_LEVEL_INFO);
            

            It's good form to set the level back. setLogLevel() returns the current log level, so you can do this:


            $oldLogLevel = $modx->setLogLevel(modX::LOG_LEVEL_INFO);;
            
            // your code
            
            $modx->setLogLevel($oldLogLevel);
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting
              • 50722
              • 35 Posts
              Many thanks for that.

              In the 1st instance i am trying to replicate the sort of thing i would get in a typical php ParseError, namely a description and placement i.e. line number, filename.

              What i did was removed commas, semi-colons etc to cause standard syntax errors in Wayfinder; the site broke front-end as predicted. However, i get quite vague reports in Error Log, and there is no ParseError message at front-end. I tested this at all Error report levels, 1-4.

              At level 4 these are the errors i get:
              [2015-07-09 12:30:45] (DEBUG @ /modx/demo/manager/index.php) Language string not found: "media_desc"
              [2015-07-09 15:05:36] (ERROR @ /modx/demo/connectors/lang.js.php) Error caching action map mgr/actions
              [2015-07-09 15:10:20] (DEBUG @ /modx/demo/manager/index.php) Language string not found: "media_desc"
              


              There is no ref to Wayfinder at all but effectively i broke the site.

              It is ok in this test case as i know what is wrong but that won't always be the case - how can i get the error reporting to be more fine grained?

              Thanks in advance.
              • If there is a fatal PHP error, then MODX cannot run to write anything to its own logs. The fatal PHP error will be in the server's PHP error logs.

                Remember, the Wayfinder snippet's cached file is included into the MODX index.php file just like any other .php file can be included, so a fatal PHP error introduced in one of these included files will kill the entire MODX index.php PHP process.
                  Studying MODX in the desert - http://sottwell.com
                  Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                  Join the Slack Community - http://modx.org
                • discuss.answer
                  • 3749
                  • 24,544 Posts
                  If you turn on error reporting in PHP, you'll see PHP errors on the screen, though you almost never want to do that on a production site (except maybe temporarily to find a problem).

                  The error will usually list the file and a line number, though often it will be a cache file where the filename is a number indicating the ID of the MODX object and the path will tell you whether it's a snippet or plugin.

                    Did I help you? Buy me a beer
                    Get my Book: MODX:The Official Guide
                    MODX info for everyone: http://bobsguides.com/modx.html
                    My MODX Extras
                    Bob's Guides is now hosted at A2 MODX Hosting
                    • 50722
                    • 35 Posts
                    Thanks for the replies apologies for the tardy response.

                    @sottwell - ok i'll have to take your word for that!
                    From what i've read before, I understood it that plugins are nowhere near the core so i assumed MODX could write Error Logs irrespective of whether a plugin causes a parse error, or any other type of error.

                    @BobRay - for development turning on php error reporting will be perfect and that is what's been suggested from other devs i'm working with. tbh i thought those front-end parse error reports happened as a php default - eg if an upgrade borks.

                    I find it a pity that Error Logs can't report these standard type parse errors, but reading what @sottwell wrote i can see why. Pity though! [ed. note: powellian last edited this post 8 years, 9 months ago.]