Skip to content

Commit 32e6cc7

Browse files
Update v15
1 parent 75bd098 commit 32e6cc7

File tree

1 file changed

+9
-8
lines changed
  • 15/umbraco-cms/fundamentals/code/debugging

1 file changed

+9
-8
lines changed

15/umbraco-cms/fundamentals/code/debugging/logging.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
In Umbraco we use the underlying logging framework of [Serilog](https://serilog.net/).
44

5-
Out of the box we write a JSON log file that contains a more rich logfile, that allows tools to perform searches & correlation on log patterns a lot easier.
5+
Out of the box, we write a JSON log file that contains a more detailed logfile. This allows tools to perform searches and correlations on log patterns more efficiently.
66

77
The default location of this file is written to `umbraco/Logs` and contains the Machine name, along with the date too:
88

@@ -22,7 +22,7 @@ Serilog is a logging framework that allows us to do structured logging or write
2222
2021-08-10 09:33:23,677 [P25776/D1/T22] INFO Umbraco.Cms.Core.Services.Implement.ContentService - Document Home (id=1062) has been published.
2323
```
2424

25-
Here is an example of the same log message represented as JSON, you can see here we have much more information that would allow us to search & filter logs based on these properties with an appropriate logging system.
25+
Here is an example of the same log message represented as JSON. You can see that we have much more information. This would allow us to search and filter logs based on these properties with an appropriate logging system.
2626

2727
```json
2828
{
@@ -48,13 +48,13 @@ Here is an example of the same log message represented as JSON, you can see here
4848
}
4949
```
5050

51-
To learn more about structured logging and message templates you can read more about it over on the [https://messagetemplates.org](https://messagetemplates.org) website or alternatively watch this video from the Serilog creator - [https://www.youtube.com/watch?v=OhmNp8UPEEg](https://www.youtube.com/watch?v=OhmNp8UPEEg)
51+
To learn more about structured logging and message templates you can read more about it over on the [https://messagetemplates.org](https://messagetemplates.org) website. Alternatively watch this video from the Serilog creator - [https://www.youtube.com/watch?v=OhmNp8UPEEg](https://www.youtube.com/watch?v=OhmNp8UPEEg)
5252

5353
## Writing to the log
5454

55-
Umbraco writes log messages, but you are also able to use the Umbraco logger to write the log file as needed, so you can get further insights and details about your implementation.
55+
Umbraco writes log messages, but you are also able to use the Umbraco logger to write the log file as needed. This allows you to gain further insights and details about your implementation.
5656

57-
Here is an example of using the logger to write an Information message to the log which will contain one property of **Name** which will output the name variable that is passed into the method
57+
Here is an example of using the logger to write an Information message to the log. It will contain one property, **Name**, which will output the name variable that is passed into the method.
5858

5959
{% hint style="warning" %}
6060
The example below uses UmbracoApiController which is obsolete in Umbraco 14 and will be removed in Umbraco 15.
@@ -63,11 +63,12 @@ The example below uses UmbracoApiController which is obsolete in Umbraco 14 and
6363
```csharp
6464
using Microsoft.AspNetCore.Mvc;
6565
using Microsoft.Extensions.Logging;
66-
using Umbraco.Cms.Web.Common.Controllers;
6766

6867
namespace Umbraco.Cms.Web.UI.NetCore;
6968

70-
public class MyApiController : UmbracoApiController
69+
[ApiController]
70+
[Route("/umbraco/api/myapi")]
71+
public class MyApiController : Controller
7172
{
7273
private readonly ILogger<MyApiController> _logger;
7374

@@ -77,7 +78,7 @@ public class MyApiController : UmbracoApiController
7778
}
7879

7980
/// /umbraco/api/MyApi/SayHello?name=John
80-
[HttpGet]
81+
[HttpGet("sayhello")]
8182
public string SayHello(string name)
8283
{
8384
_logger.LogInformation("We are saying hello to {Name}", name);

0 commit comments

Comments
 (0)