Skip to content

Commit

Permalink
DOC Explicitly set log files using absolute file paths
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed Apr 12, 2023
1 parent 1e04697 commit 15bfd66
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion en/00_Getting_Started/03_Environment_Management.md
Expand Up @@ -112,7 +112,7 @@ Silverstripe core environment variables are listed here, though you're free to d
| `SS_USE_BASIC_AUTH`| Baseline protection for requests handled by Silverstripe. Usually requires additional security measures for comprehensive protection. See [Environment Types](/developer_guides/debugging/environment_types) for caveats.|
| `SS_SEND_ALL_EMAILS_TO`| If you define this constant, all emails will be redirected to this address.|
| `SS_SEND_ALL_EMAILS_FROM`| If you define this constant, all emails will be sent from this address.|
| `SS_ERROR_LOG` | Relative path to the log file. |
| `SS_ERROR_LOG` | Relative path to the log file (see [Logging and Error Handling](/developer_guides/debugging/error_handling/#logging-to-a-file)). |
| `SS_PROTECTED_ASSETS_PATH` | Path to secured assets - defaults to ASSETS_PATH/.protected |
| `SS_DATABASE_MEMORY` | Used for SQLite3 DBs |
| `SS_TRUSTED_PROXY_IPS` | IP address or CIDR range to trust proxy headers from. If left blank no proxy headers are trusted. Can be set to 'none' (trust none) or '*' (trust all) |
Expand Down
15 changes: 11 additions & 4 deletions en/02_Developer_Guides/07_Debugging/01_Error_Handling.md
Expand Up @@ -163,12 +163,19 @@ SilverStripe\Core\Injector\Injector:
LogFileHandler:
class: Monolog\Handler\StreamHandler
constructor:
- "../silverstripe.log"
- "/var/www/silverstripe.log"
- "info"
```

The log file will be relative to the main index.php file path (default: inside public/), so "../silverstripe.log" will
create a file in your project root.
[warning]
The log file path must be an absolute file path, as relative paths may behave differently between CLI and HTTP requests. If you want to use a _relative_ path, you can use the `SS_ERROR_LOG` environment variable to declare a file path that is relative to your project root:

```sh
SS_ERROR_LOG="./silverstripe.log"
```

You don't need any of the yaml configuration above if you are using the `SS_ERROR_LOG` environment variable - but you can use a combination of the environment variable and yaml configuration if you want to configure multiple error log files.
[/warning]

The `info` argument provides the minimum level to start logging at.

Expand Down Expand Up @@ -231,7 +238,7 @@ SilverStripe\Core\Injector\Injector:
LogFileHandler:
class: Monolog\Handler\StreamHandler
constructor:
- "../silverstripe.log"
- "/var/www/silverstripe.log"
- "notice"
properties:
Formatter: '%$Monolog\Formatter\HtmlFormatter'
Expand Down

0 comments on commit 15bfd66

Please sign in to comment.