Find error log in linux

Where are all the major log files located?

So, if there is some problem with my computer, be it hardware or software, what are the major log files and where are they located? Also, is there a generic location where log files of the other packages might be located?

3 Answers 3

All log files are located in /var/log directory. In that directory, there are specific files for each type of logs. For example, system logs, such as kernel activities are logged in syslog file.

Some of the most common log files in that directory is :

  • In directory apt there is a file history.log which saves all the package installation and removal information even the initial system build as Live CD. You can open this file to see this very interesting file.
  • In directory dist-upgrade there is a file apt.log which logs the information during distribution upgrades
  • In directory installer the log files which are created during installation can be found.
  • There is an apport.log file which saves information about crashes in your system and reporting them.
  • The file auth.log includes information about the authentication activities such as when you authenticate as root user via sudo.
  • The file dpkg.log saves the low level details of package installation and removal related with dpkg . You might be aware that the apt system depends on dpkg for package installation and removal.
  • boot.log includes information of each booting.
  • kern.log saves kernel information such as warnings, errors etc.
  • alternatives.log includes the history of all the alternatives set by various packages and their removal via update-alternatives command.
  • Another important log file is Xorg.log which include information about the graphics driver, its failures, warnings etc.

Some other types of Log files may be there depending on your installed packages. For example, My system also includes a log files epoptes.log which will only be there if you install epoptes package.

Changes after systemd

With the advent of systemd , logging is mostly handled by journalctl utility and store the logs in binary format in /var/lib/systemd/catalog/database file. This file enumerates all logs including kernel, boot and application logs and provides required logs via journalctl utility.

Here is a good article on journalctl on how you can use it to fetch required log info.

Источник

How to Find & Remove Large error_log Files in Linux

In this tutorial, you will learn how to find and remove large error_log files generated by your scripts, while running from a Linux platform.

Читайте также:  What is tracert in linux

How to Find error_log Files in Linux

List the Error Log files with its disk space usage details:

# find . -type f -iname error_log -exec du -sh <> \;
  • type : Specify the type to find.
  • iname: Specify the name to find.
  • exec: Execute the “du -sch” and lists the output with file size.

How to Find and Delete error_log Files in Linux

# find . -type f -iname error_log -delete

How to Find All the error_log Files Larger Than 1 GB

To find all the error_log files larger than 1 GB (1,073,741,824 bytes) in the current directory and its subdirectories, you can use the following command:

find . -type f -name "error_log" -size +1000000000c -exec ls -lh <> \;

Explanation of the command options:

  • find . : start searching from the current directory ( . )
  • -type f : only look for files (not directories)
  • -name «error_log» : only consider files with the name “error_log”
  • -size +1000000000c : only consider files that are larger than 1 GB (1,000,000,000 bytes)
  • -exec ls -lh <> \; : run the ls -lh command on each file found, displaying its size in human-readable format. The <> placeholder is replaced with the path to each file, and the \; is used to end the exec command.

The ls -lh command displays information about the files, including their size, permissions, and modification date. The -h option makes the size human-readable, so it will show values like “1.0G” instead of “1000000000”.

How to Find and Remove All the error_log Files Larger Than 1 GB

find . -type f -name "error_log" -size +1000000000c -exec rm <> \;

Explanation of the command options:

  • find . : start searching from the current directory ( . )
  • -type f : only look for files (not directories)
  • -name «error_log» : only consider files with the name “error_log”
  • -size +1000000000c : only consider files that are larger than 1 GB (1,000,000,000 bytes)
  • -exec rm <> \; : run the rm command on each file found, removing it from the file system. The <> placeholder is replaced with the path to each file, and the \; is used to end the exec command.

Note: The rm command permanently deletes files. Make sure you want to delete the files before running this command, as it does not send the files to the trash bin or provide any means to recover the deleted files.

Tired of hassling with website issues? ChemiCloud is the managed hosting solution designed to save you time and money! 🤓 Check out our web hosting plans!

How to Find and Delete error_log Files using a Cron job

If you want to automatically remove all the error_log files which are being generated, you can achieve this by setting up a cron job.

The command that the cron job should execute is:

/bin/find /home/user -type f -iname error_log -delete

Example: 0 * * * * /bin/find /home/eatat/ -type f -iname error_log -delete

Источник

Finding where PHP errors are logged on Ubuntu server?

I can’t find the PHP error logs are on the ubuntu server. Checking phpinfo() has «no value» for error_log. If I run a locate error_log I get nothing for the domain I am working with. This site is on a shared server, so I’m not sure I’ll be able to change anything in php.ini — Where are the PHP error logs?

Читайте также:  Linux parted создать раздел

I just do a comment, but why don’t you write a function for logging with different loglevels? PS: Concerning your question; I guess you took a look at /var/log/apache?!

3 Answers 3

Check the main Apache error log for the host:

This site is on a shared server

Then you need to ask your web host where the log file(s) are located.

It’s entirely up to them where and how each virtual host has its logs written.

Usually on shared servers where virtual hosts are concerned, each vhost has its own unique error_log and access_log files.

On some hosts, these are typically in your home directory under a folder called logs. If you don’t see any directory in your home that looks like it stores logs, log into your hosting control panel and see if you can get access to them there. For example, cPanel has a section called logs , where you can find an item called Error Log which would show you the contents of the Apache error log for your virtual host.

This question is in a collective: a subcommunity defined by tags with relevant content and experts.

Источник

Как посмотреть логи в Linux

Системные администраторы, да и обычные пользователи Linux, часто должны смотреть лог файлы для устранения неполадок. На самом деле, это первое, что должен сделать любой сисадмин при возникновении любой ошибки в системе.

Сама операционная система Linux и работающие приложения генерируют различные типы сообщений, которые регистрируются в различных файлах журналов. В Linux используются специальное программное обеспечение, файлы и директории для хранения лог файлов. Знание в каких файлах находятся логи каких программ поможет вам сэкономить время и быстрее решить проблему. В этой статье мы рассмотрим основные части системы логирования в Linux, файлы логов, а также утилиты, с помощью которых можно посмотреть логи Linux.

Расположение логов по умолчанию

Большинство файлов логов Linux находятся в папке /var/log/ вы можете список файлов логов для вашей системы с помощью команды ls:

Ниже мы рассмотрим 20 различных файлов логов Linux, размещенных в каталоге /var/log/. Некоторые из этих логов встречаются только в определенных дистрибутивах, например, dpkg.log встречается только в системах, основанных на Debian.

  • /var/log/messages — содержит глобальные системные логи Linux, в том числе те, которые регистрируются при запуске системы. В этот лог записываются несколько типов сообщений: это почта, cron, различные сервисы, ядро, аутентификация и другие.
  • /var/log/dmesg — содержит сообщения, полученные от ядра. Регистрирует много сообщений еще на этапе загрузки, в них отображается информация об аппаратных устройствах, которые инициализируются в процессе загрузки. Можно сказать это еще один лог системы Linux. Количество сообщений в логе ограничено, и когда файл будет переполнен, с каждым новым сообщением старые будут перезаписаны. Вы также можете посмотреть сообщения из этого лога с помощью команды dmseg.
  • /var/log/auth.log — содержит информацию об авторизации пользователей в системе, включая пользовательские логины и механизмы аутентификации, которые были использованы.
  • /var/log/boot.log — Содержит информацию, которая регистрируется при загрузке системы.
  • /var/log/daemon.log — Включает сообщения от различных фоновых демонов
  • /var/log/kern.log — Тоже содержит сообщения от ядра, полезны при устранении ошибок пользовательских модулей, встроенных в ядро.
  • /var/log/lastlog — Отображает информацию о последней сессии всех пользователей. Это нетекстовый файл, для его просмотра необходимо использовать команду lastlog.
  • /var/log/maillog /var/log/mail.log — журналы сервера электронной почты, запущенного в системе.
  • /var/log/user.log — Информация из всех журналов на уровне пользователей.
  • /var/log/Xorg.x.log — Лог сообщений Х сервера.
  • /var/log/alternatives.log — Информация о работе программы update-alternatives. Это символические ссылки на команды или библиотеки по умолчанию.
  • /var/log/btmp — лог файл Linux содержит информацию о неудачных попытках входа. Для просмотра файла удобно использовать команду last -f /var/log/btmp
  • /var/log/cups — Все сообщения, связанные с печатью и принтерами.
  • /var/log/anaconda.log — все сообщения, зарегистрированные при установке сохраняются в этом файле
  • /var/log/yum.log — регистрирует всю информацию об установке пакетов с помощью Yum.
  • /var/log/cron — Всякий раз когда демон Cron запускает выполнения программы, он записывает отчет и сообщения самой программы в этом файле.
  • /var/log/secure — содержит информацию, относящуюся к аутентификации и авторизации. Например, SSHd регистрирует здесь все, в том числе неудачные попытки входа в систему.
  • /var/log/wtmp или /var/log/utmp — системные логи Linux, содержат журнал входов пользователей в систему. С помощью команды wtmp вы можете узнать кто и когда вошел в систему.
  • /var/log/faillog — лог системы linux, содержит неудачные попытки входа в систему. Используйте команду faillog, чтобы отобразить содержимое этого файла.
  • /var/log/mysqld.log — файлы логов Linux от сервера баз данных MySQL.
  • /var/log/httpd/ или /var/log/apache2 — лог файлы linux11 веб-сервера Apache. Логи доступа находятся в файле access_log, а ошибок в error_log
  • /var/log/lighttpd/ — логи linux веб-сервера lighttpd
  • /var/log/conman/ — файлы логов клиента ConMan,
  • /var/log/mail/ — в этом каталоге содержатся дополнительные логи почтового сервера
  • /var/log/prelink/ — Программа Prelink связывает библиотеки и исполняемые файлы, чтобы ускорить процесс их загрузки. /var/log/prelink/prelink.log содержит информацию о .so файлах, которые были изменены программой.
  • /var/log/audit/— Содержит информацию, созданную демоном аудита auditd.
  • /var/log/setroubleshoot/ — SE Linux использует демон setroubleshootd (SE Trouble Shoot Daemon) для уведомления о проблемах с безопасностью. В этом журнале находятся сообщения этой программы.
  • /var/log/samba/ — содержит информацию и журналы файлового сервера Samba, который используется для подключения к общим папкам Windows.
  • /var/log/sa/ — Содержит .cap файлы, собранные пакетом Sysstat.
  • /var/log/sssd/ — Используется системным демоном безопасности, который управляет удаленным доступом к каталогам и механизмами аутентификации.
Читайте также:  How to install php on linux ubuntu

Просмотр логов в Linux

Чтобы посмотреть логи на Linux удобно использовать несколько утилит командной строки Linux. Это может быть любой текстовый редактор, или специальная утилита. Скорее всего, вам понадобятся права суперпользователя для того чтобы посмотреть логи в Linux. Вот команды, которые чаще всего используются для этих целей:

Я не буду останавливаться подробно на каждой из этих команд, поскольку большинство из них уже подробно рассмотрены на нашем сайте. Но приведу несколько примеров. Просмотр логов Linux выполняется очень просто:

Смотрим лог /var/log/dmesg, с возможностью прокрутки:

Источник

Оцените статью
Adblock
detector