Magento 2 update.log aumenta le dimensioni significative ogni minuto


9

AGGIORNARE:

Ho finito per usare l'utilità logrotate per gestire i file di registro in continua crescita. Ho anche impostato alcuni lavori cron che controllano di volta in volta i file temporanei non necessari.


Ho il cron standard di Magento 2 configurato e funzionante. Dopo due giorni, ho riscontrato alcuni problemi durante l'esecuzione di alcune azioni nel Pannello di amministrazione. Quando ho controllato i registri del server, ho scoperto che si trattava di un problema di spazio su disco. Dopo ulteriori indagini, ho scoperto che questo update.log.txtè il colpevole. Le dimensioni del file aumentavano di> 1 MB ogni minuto. C'è stato un tempo che ha raggiunto più di 20 GB.

inserisci qui la descrizione dell'immagine

È normale per una configurazione standard di Magento 2? O posso e come posso disabilitarlo o almeno minimizzarlo?

Succede sia allo sviluppatore che alla modalità di produzione.

L'installazione di Cron si basava su questa guida .

Scheda Cron:

* * * * * <path to php binary> <magento install dir>/bin/magento cron:run | grep -v "Ran jobs by schedule" >> <magento install dir>/var/log/magento.cron.log
* * * * * <path to php binary> <magento install dir>/update/cron.php >> <magento install dir>/var/log/update.cron.log
* * * * * <path to php binary> <magento install dir>/bin/magento setup:cron:run >> <magento install dir>/var/log/setup.cron.log

CONTENUTO DEL CAMPIONE

/var/www/html/setup/src/Magento/Setup/Console/Command/I18nCollectPhrasesCommand.php /var/www/html/setup/src/Magento/Setup/Console/Command/MaintenanceStatusCommand.php / var / www / html /setup/src/Magento/Setup/Console/Command/BackupCommand.php /var/www/html/setup/src/Magento/Setup/Console/Command/DependenciesShowFrameworkCommand.php / var / www / html / setup / src / Magento /Setup/Console/Command/UninstallCommand.php /var/www/html/setup/src/Magento/Setup/Console/Command/InfoTimezoneListCommand.php / var / www / html / setup / src / Magento / Setup / Console / Command /Montaggio / www / html / setup / src / Magento / Setup / Console / comando / InfoBackupsListCommand.php /var/www/html/setup/src/Magento/Setup/Console/Command/MaintenanceDisableCommand.php /var/www/html/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php / var / www / html / setup / src / Magento / Setup / Console / Command / InstallCommand.php /var/www/html/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php / var / www / html / setup / src / Magento / Setup / Fixtures / IndexersStatesApplyFixture.php /var/www/html/setup/src/Magento/Setup/Fixtures/StoresFixture.php /var/www/html/setup/src/Magento/Setup/Fixtures/CategoriesFixture.php / var / www / html / setup / src / Magento / Setup / Fixtures / SimpleProductsFixture.php /var/www/html/setup/src/Magento/Setup/Fixtures/tax_rates.csv / var / www / html / setup / src / Magento / Setup / Validator / var / www / html / setup / src / Magento / Setup / Validator / DbValidator.php /var/www/html/setup/src/Magento/Setup/Validator/IpValidator.php /var/www/html/setup/src/Magento/Setup/Validator/AdminCredentialsValidator.php / var / www / html / setup / index.php / var / www / html / setup / performance-toolkit /var/www/html/setup/performance-toolkit/.htaccess / var / www / html / setup / performance-toolkit / profiles / var / www / html / setup / performance-toolkit / profiles / ce /var/www/html/setup/performance-toolkit/profiles/ce/large.xml /var/www/html/setup/performance-toolkit/profiles/ce/small.xml /var/www/html/setup/performance-toolkit/profiles/ce/medium.xml /var/www/html/setup/performance-toolkit/profiles/ce/extra_large.xml / var / www / html / setup / performance -toolkit / README.txt /var/www/html/setup/performance-toolkit/benchmark.jmx /var/www/html/vendor/.htaccess [] []php /var/www/html/setup/src/Magento/Setup/Validator/AdminCredentialsValidator.php /var/www/html/setup/index.php / var / www / html / setup / performance-toolkit / var / www / html / setup / performance-toolkit / .htaccess / var / www / html / setup / performance-toolkit / profiles / var / www / html / setup / performance-toolkit / profiles / ce / var / www / html / setup / performance -toolkit / profiles / ce / large.xml /var/www/html/setup/performance-toolkit/profiles/ce/small.xml /var/www/html/setup/performance-toolkit/profiles/ce/medium.xml /var/www/html/setup/performance-toolkit/profiles/ce/extra_large.xml /var/www/html/setup/performance-toolkit/README.txt / var / www / html / setup / performance-toolkit / benchmark .jmx /var/www/html/vendor/.htaccess [] []php /var/www/html/setup/src/Magento/Setup/Validator/AdminCredentialsValidator.php /var/www/html/setup/index.php / var / www / html / setup / performance-toolkit / var / www / html / setup / performance-toolkit / .htaccess / var / www / html / setup / performance-toolkit / profiles / var / www / html / setup / performance-toolkit / profiles / ce / var / www / html / setup / performance -toolkit / profiles / ce / large.xml /var/www/html/setup/performance-toolkit/profiles/ce/small.xml /var/www/html/setup/performance-toolkit/profiles/ce/medium.xml /var/www/html/setup/performance-toolkit/profiles/ce/extra_large.xml /var/www/html/setup/performance-toolkit/README.txt / var / www / html / setup / performance-toolkit / benchmark .jmx /var/www/html/vendor/.htaccess [] []php / var / www / html / setup / performance-toolkit /var/www/html/setup/performance-toolkit/.htaccess / var / www / html / setup / performance-toolkit / profiles / var / www / html / setup / performance-toolkit / profiles / ce /var/www/html/setup/performance-toolkit/profiles/ce/large.xml /var/www/html/setup/performance-toolkit/profiles/ce/small.xml / var /www/html/setup/performance-toolkit/profiles/ce/medium.xml /var/www/html/setup/performance-toolkit/profiles/ce/extra_large.xml / var / www / html / setup / performance-toolkit /README.txt /var/www/html/setup/performance-toolkit/benchmark.jmx /var/www/html/vendor/.htaccess [] []php / var / www / html / setup / performance-toolkit /var/www/html/setup/performance-toolkit/.htaccess / var / www / html / setup / performance-toolkit / profiles / var / www / html / setup / performance-toolkit / profiles / ce /var/www/html/setup/performance-toolkit/profiles/ce/large.xml /var/www/html/setup/performance-toolkit/profiles/ce/small.xml / var /www/html/setup/performance-toolkit/profiles/ce/medium.xml /var/www/html/setup/performance-toolkit/profiles/ce/extra_large.xml / var / www / html / setup / performance-toolkit /README.txt /var/www/html/setup/performance-toolkit/benchmark.jmx /var/www/html/vendor/.htaccess [] []htaccess / var / www / html / setup / performance-toolkit / profiles / var / www / html / setup / performance-toolkit / profiles / ce / var / www / html / setup / performance-toolkit / profiles / ce / large. xml /var/www/html/setup/performance-toolkit/profiles/ce/small.xml /var/www/html/setup/performance-toolkit/profiles/ce/medium.xml / var / www / html / setup / performance-toolkit / profiles / ce / extra_large.xml /var/www/html/setup/performance-toolkit/README.txt /var/www/html/setup/performance-toolkit/benchmark.jmx / var / www / html / vendor / .htaccess [] []htaccess / var / www / html / setup / performance-toolkit / profiles / var / www / html / setup / performance-toolkit / profiles / ce / var / www / html / setup / performance-toolkit / profiles / ce / large. xml /var/www/html/setup/performance-toolkit/profiles/ce/small.xml /var/www/html/setup/performance-toolkit/profiles/ce/medium.xml / var / www / html / setup / performance-toolkit / profiles / ce / extra_large.xml /var/www/html/setup/performance-toolkit/README.txt /var/www/html/setup/performance-toolkit/benchmark.jmx / var / www / html / vendor / .htaccess [] []txt /var/www/html/setup/performance-toolkit/benchmark.jmx /var/www/html/vendor/.htaccess [] []txt /var/www/html/setup/performance-toolkit/benchmark.jmx /var/www/html/vendor/.htaccess [] []

Ho trovato alcuni posti in cui questo registro potrebbe essere generato / aggiornato:

<INSTALL_DIR>setup\src\Magento\Setup\Console\Command\CronRunCommand.php:
       75      protected function execute(InputInterface $input, OutputInterface $output)
       76      {
       77:         $notification = 'setup-cron: Please check var/log/update.log for execution summary.';
       78  
       79          if (!$this->deploymentConfig->isAvailable()) {

    <INSTALL_DIR>setup\src\Magento\Setup\Model\Cron\ReadinessCheck.php:
      164          $write->writeFile(self::SETUP_CRON_JOB_STATUS_FILE, $resultJson);
      165  
      166:         // write to permanent log file, var/log/update.log
      167          foreach ($errorLogMessages as $errorLog) {
      168              $this->status->add($errorLog, \Psr\Log\LogLevel::ERROR, false);

    <INSTALL_DIR>setup\src\Magento\Setup\Model\Cron\SetupLoggerFactory.php:
       22      {
       23          $logger = new \Monolog\Logger($channelName);
       24:         $path = BP . '/var/log/update.log';
       25          $logger->pushHandler(new \Monolog\Handler\StreamHandler($path));
       26          return $logger;

    <INSTALL_DIR>setup\src\Magento\Setup\Model\Cron\SetupStreamHandler.php:
       17       * @var string
       18       */
       19:     protected $fileName = '/var/log/update.log';
       20  
       21      /**

    <INSTALL_DIR>setup\src\Magento\Setup\Model\Cron\Status.php:
       81          $this->varReaderWriter = $filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
       82          $this->statusFilePath = $statusFilePath ? $statusFilePath : '.update_status.txt';
       83:         $this->logFilePath = $logFilePath ? $logFilePath : DirectoryList::LOG . '/update.log';
       84          $this->updateInProgressFlagFilePath = $updateInProgressFlagFilePath
       85              ? $updateInProgressFlagFilePath

    <INSTALL_DIR>setup\src\Magento\Setup\Test\Unit\Model\Cron\StatusTest.php:
       71          $this->varReaderWriter->expects($this->any())
       72              ->method('getAbsolutePath')
       73:             ->with('log/update.log')
       74:             ->willReturn('DIR/var/log/update.log');
       75:         $this->assertEquals('DIR/var/log/update.log', $this->status->getLogFilePath());
       76      }
       77  

    <INSTALL_DIR>update\app\code\Magento\Update\CronReadinessCheck.php:
       16      const CRON_JOB_STATUS_FILE = '.update_cronjob_status';
       17  
       18:     const UPDATE_CRON_LOG_FILE = 'var/log/update.log';
       19  
       20      /**#@+
       ..
       91          file_put_contents(MAGENTO_BP . '/var/' . self::CRON_JOB_STATUS_FILE, $resultJson);
       92  
       93:         // If non-accessible paths are found, log an 'error' entry for the same in update.log
       94          if ( !$success && !empty($outputString) ) {
       95              $updateLoggerFactory = new UpdateLoggerFactory();

    <INSTALL_DIR>update\app\code\Magento\Update\Status.php:
       67      ) {
       68          $this->statusFilePath = $statusFilePath ? $statusFilePath : MAGENTO_BP . '/var/.update_status.txt';
       69:         $this->logFilePath = $logFilePath ? $logFilePath : MAGENTO_BP . '/var/log/update.log';
       70          $this->updateInProgressFlagFilePath = $updateInProgressFlagFilePath
       71              ? $updateInProgressFlagFilePath

    <INSTALL_DIR>update\app\code\Magento\Update\UpdateLoggerFactory.php:
       29       */
       30      public function __construct(
       31:         $logFile = '/var/log/update.log',
       32          $channelName = 'update-cron'
       33      ) {

    <INSTALL_DIR>update\cron.php:
       15  $status = new \Magento\Update\Status();
       16  $cronReadinessChecker = new \Magento\Update\CronReadinessCheck();
       17: $notification = 'update-cron: Please check var/log/update.log for execution summary.' . PHP_EOL;
       18  
       19  if (!$cronReadinessChecker->runReadinessCheck()) {

    <INSTALL_DIR>update\dev\tests\integration\testsuite\Magento\Update\StatusTest.php:
       43          $this->statusFilePath = __DIR__ . '/_files/update_status.txt';
       44          $this->tmpStatusFilePath = TESTS_TEMP_DIR . '/update_status.txt';
       45:         $this->tmpStatusLogFilePath = TESTS_TEMP_DIR . '/update.log';
       46          $this->updateInProgressFlagFilePath = TESTS_TEMP_DIR . '/update_in_progress.flag';
       47          $this->updateErrorFlagFilePath = TESTS_TEMP_DIR . '/update_error.flag';

AGGIORNARE:

Ho finito per usare l'utilità logrotate per gestire i file di registro in continua crescita. Ho anche impostato alcuni lavori cron che controllano di volta in volta i file temporanei non necessari.


1
Sto riscontrando lo stesso problema con il mio negozio. Il mio file update.log era 23g e in realtà il mio mysql è andato in crash ieri sera. Non sono sicuro di cosa stia succedendo: ho un'installazione abbastanza vaniglia.
Budget Woodworker

Risposte:


6

Per quanto ne so, il var/log/update.logfile viene effettivamente utilizzato con il cron.

È dichiarato in \setup\src\Magento\Setup\Model\Cron\Status.php

$this->logFilePath = $logFilePath ? $logFilePath : DirectoryList::LOG . '/update.log';

E poi recuperato tramite il getLogFilePath()metodo

Se controlli dove viene chiamato questo metodo, è sotto \setup\src\Magento\Setup\Model\Cron\JobFactory.php:

$logStream = fopen($cronStatus->getLogFilePath(), 'a+');
$streamOutput = new MultipleStreamOutput([$statusStream, $logStream]);

Quindi la $streamOutputvariabile viene passata come parametro alla classe lavoro, ad esempio:

return new JobUpgrade(
    $this->serviceLocator->get('Magento\Setup\Console\Command\UpgradeCommand'),
    $objectManagerProvider,
    $streamOutput,
    $this->serviceLocator->get('Magento\Setup\Model\Cron\Queue'),
    $cronStatus,
    $name,
    $params
);

Se continuo con questo esempio, $this->outputviene utilizzato nel execute()metodo:

$this->command->run(new ArrayInput($this->params), $this->output);

Il run()metodo è dichiarato invendor\symfony\console\Symfony\Component\Console\Command\Command.php

La $outputvariabile viene quindi utilizzata in diversi luoghi come:

    $this->initialize($input, $output);

Così come :

    if ($input->isInteractive()) {
        $this->interact($input, $output);
    }

    $input->validate();

    if ($this->code) {
        $statusCode = call_user_func($this->code, $input, $output);
    } else {
        $statusCode = $this->execute($input, $output);
    }

Un altro interessante:

        } elseif (OutputInterface::VERBOSITY_VERY_VERBOSE === $output->getVerbosity()) {
            $output->writeln('<comment>Install the proctitle PECL to be able to change the process title.</comment>');
        }

Secondo quest'ultimo codice, alcune cose possono essere scritte in caso di parametri molto dettagliati. Forse hai impostato i tuoi lavori cron con -vved è per questo che roba viene registrata.

Questa non è una risposta definitiva, ma dovresti seguire quella traccia dello stack che ti ho appena dato per indagare sul problema.


2

Probabilmente hai impostato autorizzazioni errate su alcune cartelle. / update / cron elenca tutte le cartelle con autorizzazioni errate

Il modo più semplice è semplicemente commentare nell'aggiornamento e nella configurazione di crontab

#* * * * * <path to php binary> <magento install dir>/update/cron.php >> <magento install dir>/var/log/update.cron.log
#* * * * * <path to php binary> <magento install dir>/bin/magento setup:cron:run >> <magento install dir>/var/log/setup.cron.log

Non ti servono se non hai bisogno di aggiornare e installare dal pannello di amministrazione.

È un'idea pericolosa per il server di produzione. È possibile aggiornare manualmente tramite compositore sul server di test / locale; Provalo; quindi copiare gli aggiornamenti sul server di produzione.

Quello di cui hai davvero bisogno è

* * * * * <path to php binary> <magento install dir>/bin/magento cron:run | grep -v "Ran jobs by schedule" >> <magento install dir>/var/log/magento.cron.log

Gestisce "indicizzatori, invia e-mail automatizzate, genera la sitemap e così via" - come descritto in devdocs


Sì, questo è stato indicato anche nella documentazione di Magento 2 per la configurazione di cron. Comunque abbiamo finito con logrotate e alcuni cron job personalizzati, che controllano e puliscono il file system, con l'obiettivo di ottimizzare l'utilizzo dello spazio su disco.
Reuelab,


0

Come so, update.logè il tuo file di registro personalizzato perché Magento 2 genera un registro di questo tipo di file

  • var / log / debug.log - tutte le informazioni salvate da Psr \ Log \ LoggerInterface :: debug () sono memorizzate lì.
  • var / log / exception.log - tutte le informazioni sulle eccezioni sono memorizzate lì.
  • var / log / system.log - le informazioni dagli altri livelli di registrazione vengono salvate lì.

Non sono sicuro del motivo per cui genera così tanti dati di registro nel tuo file potrebbe essere un errore di sintassi o qualcosa del genere.

Ma suggerirei di cercare con update.logcon nella directory del codice Magento 2 e rimuovere quel registro dal codice.


Ciao, grazie per aver risposto. Non penso che sia un registro personalizzato, perché posso trovarlo su alcune classi Magento predefinite. Ho aggiornato la mia domanda per ulteriori informazioni.
Reuelab,
Utilizzando il nostro sito, riconosci di aver letto e compreso le nostre Informativa sui cookie e Informativa sulla privacy.
Licensed under cc by-sa 3.0 with attribution required.