You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -30,13 +30,13 @@ Here are some example queries to help you get started. For more details on the s
30
30
31
31
If you frequently use a custom query, you can save it for quick access. Type your query in the search box and click the heart icon to save it with a friendly name. Saved queries are stored in the `umbracoLogViewerQuery` table in the database.
32
32
33
-
## Implementing Your Own Log Viewer
33
+
## Implementing Your Own Log Viewer Source
34
34
35
-
Umbraco allows you to implement a customn `ILogViewer` to fetch logs from alternative sources, such as **Azure Table Storage**.
35
+
Umbraco allows you to implement a custom `ILogViewerRepository` and `ILogViewerService` to fetch logs from alternative sources, such as **Azure Table Storage**.
36
36
37
-
### Creating a Custom Log Viewer
37
+
### Creating a Custom Log Viewer Repository
38
38
39
-
To fetch logs from Azure Table Storage, implement the `SerilogLogViewerSourceBase` class from `Umbraco.Cms.Core.Logging.Viewer`.
39
+
To fetch logs from Azure Table Storage, extend the `LogViewerRepositoryBase` class from `Umbraco.Cms.Infrastructure.Services.Implement`.
40
40
41
41
{% hint style="info" %}
42
42
This implementation requires the `Azure.Data.Tables` NuGet package.
//Replace ACCOUNT_NAME and KEY with your actual Azure Storage Account details. The "Logs" parameter refers to the table name where logs will be stored and retrieved from.
71
+
// This example uses a connection string compatible with the Azurite emulator
// Table storage does not support skip, only take, so the best we can do is to not fetch more entities than we need in total.
77
-
// See: https://learn.microsoft.com/en-us/rest/api/storageservices/writing-linq-queries-against-the-table-service#returning-the-top-n-entities for more info.
//This method is optional. If you store saved searches in Azure Table Storage, implement deleting logic here.
107
-
returnbase.DeleteSavedSearch(name, query);
135
+
publicrequiredstringPartitionKey { get; set; }
136
+
137
+
publicrequiredstringRowKey { get; set; }
138
+
139
+
publicDateTimeOffset? Timestamp { get; set; }
140
+
141
+
publicETagETag { get; set; }
108
142
}
109
143
}
144
+
```
145
+
146
+
Azure Table Storage requires entities to implement the `ITableEntity` interface. Since Umbraco's default log entity does not implement this, a custom entity (`AzureTableLogEntity`) must be created to ensure logs are correctly fetched.
The next thing to do is create a new implementation of `ILogViewerService`. Amongst other things, this is responsible for figuring out whether a provided log query is allowed. Again a base class is available.
Azure Table Storage requires entities to implement the `ITableEntity` interface. Since Umbraco’s default log entity does not implement this, a custom entity (`AzureTableLogEntity`) must be created to ensure logs are correctly fetched and stored.
120
-
121
-
### Register implementation
185
+
### Register implementations
122
186
123
-
Umbraco needs to be made aware that there is a new implementation of an `ILogViewer` to register. We also need to replace the default JSON LogViewer that we ship in the core of Umbraco.
187
+
Umbraco needs to be made aware that there is a new implementation of an `ILogViewerRepository` and an `ILogViewerService`. These need to replace the default ones that are shipped with Umbraco.
With the above two classes, the setup is in place to view logs from an Azure Table. However, logs are not yet persisted into the Azure Table Storage account. To enable persistence, configure the Serilog logging pipeline to store logs in Azure Table Storage.
209
+
With the above three classes, the setup is in place to view logs from an Azure Table. However, logs are not yet persisted into the Azure Table Storage account. To enable persistence, configure the Serilog logging pipeline to store logs in Azure Table Storage.
140
210
141
-
* Install `Serilog.Sinks.AzureTableStorage` from NuGet.
142
-
* Add a new sink to `appsettings.json` with credentials to persist logs to Azure.
211
+
- Install `Serilog.Sinks.AzureTableStorage` from NuGet.
212
+
- Add a new sink to `appsettings.json` with credentials to persist logs to Azure.
143
213
144
214
The following sink needs to be added to the [`Serilog:WriteTo`](https://github.com/serilog/serilog-sinks-azuretablestorage#json-configuration) array.
For more in-depth information about logging and how to configure it, see the [Logging](../code/debugging/logging.md) article.
157
228
158
229
### Compact Log Viewer - Desktop App
159
230
160
-
[Compact Log Viewer](https://www.microsoft.com/store/apps/9N8RV8LKTXRJ?cid=storebadge\&ocid=badge). A desktop tool is available for viewing and querying JSON log files in the same way as the built-in Log Viewer in Umbraco.
231
+
[Compact Log Viewer](https://www.microsoft.com/store/apps/9N8RV8LKTXRJ?cid=storebadge&ocid=badge). A desktop tool is available for viewing and querying JSON log files in the same way as the built-in Log Viewer in Umbraco.
Copy file name to clipboardExpand all lines: 16/umbraco-cms/fundamentals/code/debugging/logging.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -117,6 +117,10 @@ Serilog uses levels as the primary means for assigning importance to log events.
117
117
118
118
Serilog can be configured and extended by using the .NET Core configuration such as the AppSetting.json files or environment variables. For more information, see the [Serilog config](../../../reference/configuration/serilog.md) article.
119
119
120
+
## The UmbracoFile Sink
121
+
122
+
Serilog uses the concept of Sinks to output the log messages to different places. Umbraco ships with a custom sink configuration called UmbracoFile that uses the [Serilog.Sinks.File](https://github.com/serilog/serilog-sinks-file) sink. This will save the logs to a rolling file on disk. You can disable this sink by setting its Enabled configuration flag to false, see [Serilog config](../../../reference/configuration/serilog.md) for more information.
123
+
120
124
## The logviewer dashboard
121
125
122
126
Learn more about the [logviewer dashboard](../../backoffice/logviewer.md) in the backoffice and how it can be extended.
Copy file name to clipboardExpand all lines: 16/umbraco-cms/fundamentals/setup/server-setup/running-umbraco-in-docker.md
+13-9Lines changed: 13 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,45 +8,49 @@ Docker is a platform for developing, shipping, and running applications in conta
8
8
9
9
## The Docker file system
10
10
11
-
By default, files created inside a container are written to an ephemeral, writable container layer.
11
+
By default, files created inside a container are written to an ephemeral, writable container layer.
12
12
This means that the files don't persist when the container is removed, and it's challenging to get files out of the container. Additionally, this writable layer is not suitable for performance-critical data processing.
13
13
14
14
This has implications when running Umbraco in Docker.
15
15
16
16
For more information, refer to the [Docker documentation on storage](https://docs.docker.com/engine/storage/).
17
17
18
-
### General file system consideration
18
+
### General file system consideration
19
19
20
20
In general, when working with files and Docker you work in a "push" fashion with read-only layers. When you build, you take all your files and "push" them into this read-only layer.
21
21
22
22
This means that you should avoid making files on the fly, and instead rely on building your image.
23
23
24
-
In an Umbraco context, this means you should not create or edit template, script or stylesheet files via the backoffice. These should be deployed as part of your web application and not managed via Umbraco.
24
+
In an Umbraco context, this means you should not create or edit template, script or stylesheet files via the backoffice. These should be deployed as part of your web application and not managed via Umbraco.
25
25
26
26
Similarly, you shouldn't use InMemory modelsbuilder, since that also relies on creating files on the disk. While this is not a hard requirement, it doesn't provide any value unless you are live editing your site.
27
27
28
28
Instead, configure models builder to use "source code" mode in development, and "none" in production, as [described when using runtime modes](https://docs.umbraco.com/umbraco-cms/fundamentals/setup/server-setup/runtime-modes).
29
29
30
-
31
30
### Logs
32
31
33
-
Umbraco writes logs to the `/umbraco/Logs/` directory. Due to the performance implications of writing to a writable layer,
34
-
and the limited size, it is recommended to mount a volume to this directory.
32
+
Umbraco writes logs to the `/umbraco/Logs/` directory. Due to the performance implications of writing to a writable layer, and the limited size, it is recommended to mount a volume to this directory.
33
+
34
+
You may prefer to avoid writing to disk for logs when hosting in containers. If so, you can disable this default behavior and register a custom Serilog sink to alternative storage, such as Azure Table storage.
35
+
36
+
You can also provide an alternative implementation of a common abstraction for the log viewer. In this way you can read logs from the location where you have configured them to be written.
37
+
38
+
For more on this please read the article on Umbraco's [log viewer](../../backoffice/logviewer.md).
35
39
36
40
### Data
37
41
38
42
The `/umbraco/Data/` directory is used to store temporary files, such as file uploads. Considering the limitations of the writable layer, you should also mount a volume to this directory.
39
43
40
44
### Media
41
45
42
-
It's recommended to not store media in the writable layer. This is for similar performance reasons as logs,
43
-
but also for practical hosting reasons. You likely want to persist media files between containers.
46
+
It's recommended to not store media in the writable layer. This is for similar performance reasons as logs,
47
+
but also for practical hosting reasons. You likely want to persist media files between containers.
44
48
45
49
One solution is to use bind mounts. The ideal setup, though, is to store the media and ImageSharp cache externally. For more information, refer to the [Azure Blob Storage documentation](https://docs.umbraco.com/umbraco-cms/extending/filesystemproviders/azure-blob-storage).
46
50
47
51
### Required files
48
52
49
-
Your solution may require some specific files to run, such as license files. You will need to pass these files into the container at build time, or mount them externally.
53
+
Your solution may require some specific files to run, such as license files. You will need to pass these files into the container at build time, or mount them externally.
Copy file name to clipboardExpand all lines: 16/umbraco-cms/reference/configuration/serilog.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -105,6 +105,7 @@ By default, Umbraco uses a special Serilog 'sink' that is optimized for performa
105
105
{
106
106
"Name": "UmbracoFile",
107
107
"Args": {
108
+
"Enabled": "True",
108
109
"RestrictedToMinimumLevel": "Warning",
109
110
"FileSizeLimitBytes": 1073741824,
110
111
"RollingInterval" : "Day",
@@ -117,6 +118,8 @@ By default, Umbraco uses a special Serilog 'sink' that is optimized for performa
117
118
}
118
119
```
119
120
121
+
You can also disable this sink if you do not wish to write files to disk.
122
+
120
123
## Adding a custom log property to all log items
121
124
122
125
You may wish to add a log property to all log messages. A good example could be a log property for the `environment` to determine if the log message came from `development` or `production`.
0 commit comments