Allow for configuration of log file names #19074
Open
+236
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Prerequisites
Description
This PR adds some additional options for configuring the file name used for Umbraco logging.
The request has come from Umbraco Cloud, as they find with the existing default of logging with files containing the machine name, as they found these did not get cleaned up when the machine name changes due to some moving of resources at Azure. The thinking was that it would be better to use the environment name for the Cloud case.
There could be other situations though, like when load balancing, that the machine name is useful. Perhaps as now, or in conjunction with the environment name,
To support this I've added two additional configuration settings:
This allows setting of a custom file name format, along with the arguments that should be included as a comma delimited list.
Currently only two arguments are supported:
MachineName
- outputs the machine nameEnvironmentName
- outputs the environment name ("Development", "Production" etc.)Any other values will be rejected in the validation of the application configuration.
Testing
Apply something along the lines of the configuration above, and verify the logs written to the default location of
umbraco/Logs
have the expected file name.Create some dummy files for previous dates and verify they get removed on start-up when you have applied the appropriate configuration (the default with no configuration is to remove files older than 31 days).
Remove custom logging and verify that log files are written with the file names as per the existing behaviour.