diff --git a/README.md b/README.md index e1d1f64f..3765f6ed 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ read logs from any directory. ### Features -- ๐Ÿ“‚ **View all the Monolog logs** in your `%kernel.logs_dir%` directory, +- ๐Ÿ“‚ **View all the Monolog, Apache2 or Nginx logs** in specified directories, - ๐Ÿ” **Search** the logs, - ๐ŸŽš **Filter** by log level (error, info, debug, etc.), by channel, date range or log content, - ๐ŸŒ‘ **Dark mode**, @@ -74,15 +74,15 @@ php bin/console assets:install Once the installation is complete, you will be able to access **Log Viewer** directly in your browser. -By default, the application is available at: `{APP_URL}/log-viewer`. - -(for example: `https://my-app.test/log-viewer`) +By default, it is available at: `/log-viewer` on your domain. ## Configuration - [Adding more monolog directories](docs/adding-more-monolog-directories.md) - [Modifying monolog configuration](docs/modifying-monolog-configuration.md) - [Disabling the default monolog configuration](docs/disabling-default-monolog-configuration.md) - [Adding additional log files](docs/adding-additional-log-files.md) +- [Adding apache logs](docs/configuring-apache-logs.md) +- [Adding nginx logs](docs/configuring-nginx-logs.md) - [Configuring the back home url](docs/configuring-the-back-home-route.md) -- [Advanced search queries](docs/search-queries.md) +- [Advanced search queries](docs/advanced-search-queries.md) - [Full configuration reference](docs/configuration-reference.md) diff --git a/dev/compose.yaml b/dev/compose.yaml index 9019f892..b7bff804 100644 --- a/dev/compose.yaml +++ b/dev/compose.yaml @@ -2,12 +2,14 @@ version: '3' services: nginx: + container_name: log-viewer-nginx image: nginx:stable-alpine ports: - ${NGINX_PORT:-8888}:80 volumes: - ../.:/app:rw - ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro + - log-viewer-log:/var/log/nginx:rw php-fpm: container_name: log-viewer-php diff --git a/dev/config/config.yml b/dev/config/config.yml index 72ac05a2..1a729311 100644 --- a/dev/config/config.yml +++ b/dev/config/config.yml @@ -52,3 +52,19 @@ fd_log_viewer: monolog: downloadable: true deletable: true + nginx-access: + type: nginx-access + name: Nginx access + finder: + in: "/var/log/nginx" + name: "nginx.access.log" + downloadable: true + deletable: true + nginx-error: + type: nginx-error + name: Nginx error + finder: + in: "/var/log/nginx" + name: "nginx.error.log" + downloadable: true + deletable: true diff --git a/dev/docker/nodejs/entrypoint.sh b/dev/docker/nodejs/entrypoint.sh index de5427c7..7f12629d 100644 --- a/dev/docker/nodejs/entrypoint.sh +++ b/dev/docker/nodejs/entrypoint.sh @@ -1,5 +1,5 @@ #!/bin/bash set -e -npm install --no-save +npm install --no-save --no-update-notifier --no-fund --no-audit node node_modules/vite/bin/vite.js build -w --mode development diff --git a/docs/configuration-reference.md b/docs/configuration-reference.md index 4ef65143..b84243c6 100644 --- a/docs/configuration-reference.md +++ b/docs/configuration-reference.md @@ -52,9 +52,13 @@ This entry allows you to add more log file directories to the Log Viewer. Each e ### log_files.type -**type**: `string` (`enum: monolog`) +**type**: `string` (`enum: monolog|http-access|apache-error|nginx-error`) -This is the type of log file that will be read. Currently only `monolog` is supported. +This is the type of log file that will be read. +- `monolog` is the default type and will read the default monolog log files. +- `http-access` will read the access log files of Apache and Nginx. +- `apache-error` will read the error log files of Apache. +- `nginx-error` will read the error log files of Nginx.

### log_files.name @@ -142,7 +146,7 @@ Should the log folders and files be deletable. **type**: `string|null`. -As log files can contain multiple lines per log entry, this pattern is used to find the start of a log entry. Any lines not matching +As certain log files can contain multiple lines per log entry, this pattern is used to find the start of a log entry. Any lines not matching the pattern will be appended to the line before. The default monolog regex pattern is `/^\[\d{4}-\d{2}-\d{2}[^]]*]\s+\S+\.\S+:/` and matches: diff --git a/docs/configuring-apache-logs.md b/docs/configuring-apache-logs.md new file mode 100644 index 00000000..f400e889 --- /dev/null +++ b/docs/configuring-apache-logs.md @@ -0,0 +1,40 @@ +# Configuring Apache2 logs + +To add apache2 logs to the Log Viewer, add the following to your `config/packages/fd_log_viewer.yaml` file: + +```yaml +fd_log_viewer: + log_files: + apache-access: + type: http-access + name: Apache2 access + finder: + in: "/var/log/apache2" + name: "access.log" + apache-error: + type: apache-error + name: Apache2 error + finder: + in: "/var/log/apache2" + name: "error.log" +``` + +## Access logs + +The `log_message_pattern`-regex that is used for the **access logs** is: + +```regex +/(?P\S+) (?P\S+) (?P\S+) \[(?P[^\]]+)\] "(?P\S+) (?P\S+) (?P\S+)" (?P\S+) (?P\S+) "(?P[^"]*)" "(?P[^"]*)"/ +``` + +The fields `date`, `method` and `path` are mandatory. The other fields are optional. + +## Error logs + +The `log_message_pattern`-regex that is used for the **error logs** is: + +```regex +/^\[(?.*?)\] \[(?:(?.*?):)?(?.*?)\] \[pid\s(?\d*)\](?: (?[^\]]*?))?(?: \[client (?.*):(?\d+)\]) (?.*?)(?:, referer: (?\S*?))?$/ +``` + +The fields `date`, `severity`, and `message` are mandatory. The other fields are optional. diff --git a/docs/configuring-nginx-logs.md b/docs/configuring-nginx-logs.md new file mode 100644 index 00000000..ce10e9bc --- /dev/null +++ b/docs/configuring-nginx-logs.md @@ -0,0 +1,40 @@ +# Configuring Nginx logs + +To add nginx logs to the Log Viewer, add the following to your `config/packages/fd_log_viewer.yaml` file: + +```yaml +fd_log_viewer: + log_files: + nginx-access: + type: http-access + name: Nginx access + finder: + in: "/var/log/nginx" + name: "nginx.access.log" + nginx-error: + type: nginx-error + name: Nginx error + finder: + in: "/var/log/nginx" + name: "nginx.error.log" +``` + +## Access logs + +The `log_message_pattern`-regex that is used for the **access logs** is: + +```regex +/(?P\S+) (?P\S+) (?P\S+) \[(?P[^\]]+)\] "(?P\S+) (?P\S+) (?P\S+)" (?P\S+) (?P\S+) "(?P[^"]*)" "(?P[^"]*)"/ +``` + +The fields `date`, `method` and `path` are mandatory. The other fields are optional. + +## Error logs + +The `log_message_pattern`-regex that is used for the **error logs** is: + +```regex +/^(?P[\d+/ :]+) \[(?P.+)] .*?: (?P.+?)(?:, client: (?P.+?))?(?:, server: (?P.*?))?(?:, request: "?(?P.+?)"?)?(?:, upstream: "?(?P.+?)"?)?(?:, host: "?(?P.+?)"?)?$/ +``` + +The fields `date`, `severity`, and `message` are mandatory. The other fields are optional. diff --git a/frontend/src/components/FileTree.vue b/frontend/src/components/FileTree.vue index 79a971f5..43696d4f 100644 --- a/frontend/src/components/FileTree.vue +++ b/frontend/src/components/FileTree.vue @@ -2,10 +2,8 @@ import LogFolder from '@/components/LogFolder.vue'; import bus from '@/services/EventBus'; import {useFolderStore} from '@/stores/folders'; -import {ref} from 'vue' -const selectedFolder = ref(0); -const folderStore = useFolderStore(); +const folderStore = useFolderStore(); bus.on('file-deleted', () => folderStore.update()); bus.on('folder-deleted', () => folderStore.update()); @@ -15,9 +13,7 @@ bus.on('folder-deleted', () => folderStore.update());
-
- -
+