Update guidance on creating the Logs folder (#4909)
* Update guidance on creating the Logs folder * Update directory-structure.mdpull/4910/head
parent
8a942e1a4f
commit
e1e6e91e0c
|
@ -27,12 +27,16 @@ In ASP.NET Core, the application directory, *publish*, is comprised of applicati
|
|||
The contents of the *publish* directory represents the *content root path*, also called the *application base path*, of the deployment. Whatever name is given to the *publish* directory in the deployment, its location serves as the server's physical path to the hosted application. The *wwwroot* directory, if present, only contains static assets. The *logs* directory may be included in the deployment by creating it in the project and adding the `<Target>` element shown below to your *.csproj* file or by physically creating the directory on the server.
|
||||
|
||||
```xml
|
||||
<Target Name="CreateLogsFolder" AfterTargets="AfterPublish">
|
||||
<MakeDir Directories="$(PublishDir)logs" Condition="!Exists('$(PublishDir)logs')" />
|
||||
<MakeDir Directories="$(PublishUrl)logs" Condition="!Exists('$(PublishUrl)logs')" />
|
||||
<Target Name="CreateLogsFolder" AfterTargets="Publish">
|
||||
<MakeDir Directories="$(PublishDir)Logs"
|
||||
Condition="!Exists('$(PublishDir)Logs')" />
|
||||
<WriteLinesToFile File="$(PublishDir)Logs\.log"
|
||||
Lines="Generated file"
|
||||
Overwrite="True"
|
||||
Condition="!Exists('$(PublishDir)Logs\.log')" />
|
||||
</Target>
|
||||
```
|
||||
|
||||
The first `<MakeDir>` element, which uses the `PublishDir` property, is used by the .NET Core CLI to determine the target location for the publish operation. The second `<MakeDir>` element, which uses the `PublishUrl` property, is used by Visual Studio to determine the target location. Visual Studio uses the `PublishUrl` property for compatibility with non-.NET Core projects.
|
||||
The `<MakeDir>` element creates an empty *Logs* folder in the published output. The element uses the `PublishDir` property to determine the target location for creating the folder. Several deployment methods, such as Web Deploy, skip empty folders during deployment. The `<WriteLinesToFile>` element generates a file in the *Logs* folder, which guarantees deployment of the folder to the server. Note that folder creation may still fail if the worker process doesn't have write access to the target folder.
|
||||
|
||||
The deployment directory requires Read/Execute permissions, while the *logs* directory requires Read/Write permissions. Additional directories where assets will be written require Read/Write permissions.
|
||||
The deployment directory requires Read/Execute permissions, while the *Logs* directory requires Read/Write permissions. Additional directories where assets will be written require Read/Write permissions.
|
||||
|
|
Loading…
Reference in New Issue