Skip to content

Commit

Permalink
Update loggerFactory.md
Browse files Browse the repository at this point in the history
  • Loading branch information
ShiranAvidov authored Jun 23, 2022
1 parent ab2d984 commit 5e2e190
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions docs/loggerFactory.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ If you want to change some of the fields or add some of your own, inherit the ap
```C#
public class MyAppLogzioAppender : LogzioAppender
{
protected override void ExtendValues(LoggingEvent loggingEvent, Dictionary<string, string> values)
{
values["logger"] = "MyPrefix." + values["logger"];
values["myAppClientId"] = new ClientIdProvider().Get();
}
protected override void ExtendValues(LoggingEvent loggingEvent, Dictionary<string, string> values)
{
values["logger"] = "MyPrefix." + values["logger"];
values["myAppClientId"] = new ClientIdProvider().Get();
}
}
```

Expand All @@ -128,11 +128,11 @@ Update Startup.cs file in Configure method to include the Log4Net middleware as
```C#
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
{
...
...

loggerFactory.AddLog4Net();
loggerFactory.AddLog4Net();

...
...
}
```

Expand All @@ -143,9 +143,9 @@ private readonly ILoggerFactory _loggerFactory;

public ExampleController(ILoggerFactory loggerFactory, ...)
{
_loggerFactory = loggerFactory;
_loggerFactory = loggerFactory;

...
...
}
```

Expand All @@ -155,18 +155,18 @@ In the Controller methods:
[Route("<PUT_HERE_YOUR_ROUTE>")]
public ActionResult ExampleMethod()
{
var logger = _loggerFactory.CreateLogger<ExampleController>();
var logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());
var logger = _loggerFactory.CreateLogger<ExampleController>();
var logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());

// Replace "App.config" with the config file that holds your log4net configuration
XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));
// Replace "App.config" with the config file that holds your log4net configuration
XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));

logger.LogInformation("Hello");
logger.LogInformation("Is it me you looking for?");
logger.LogInformation("Hello");
logger.LogInformation("Is it me you looking for?");

LogManager.Shutdown();
LogManager.Shutdown();

return Ok();
return Ok();
}
```

Expand Down

0 comments on commit 5e2e190

Please sign in to comment.