-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve docs for using NLog AppCenter Target with MAUI (#38)
- Loading branch information
Showing
5 changed files
with
128 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/NLog.Targets.AppCenter/Config/SetupBuilderExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using NLog.Config; | ||
|
||
namespace NLog | ||
{ | ||
/// <summary> | ||
/// Extension methods to setup LogFactory options | ||
/// </summary> | ||
public static class SetupBuilderExtensions | ||
{ | ||
/// <summary> | ||
/// Register the NLog.Web LayoutRenderers before loading NLog config | ||
/// </summary> | ||
public static ISetupBuilder RegisterAppCenter(this ISetupBuilder setupBuilder) | ||
{ | ||
setupBuilder.SetupExtensions(e => e.RegisterAppCenter()); | ||
return setupBuilder; | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/NLog.Targets.AppCenter/Config/SetupExtensionsBuilderExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using NLog.Config; | ||
using NLog.Targets; | ||
|
||
namespace NLog | ||
{ | ||
/// <summary> | ||
/// Extension methods to setup NLog extensions, so they are known when loading NLog LoggingConfiguration | ||
/// </summary> | ||
public static class SetupExtensionsBuilderExtensions | ||
{ | ||
/// <summary> | ||
/// Register the NLog.Web LayoutRenderers | ||
/// </summary> | ||
public static ISetupExtensionsBuilder RegisterAppCenter(this ISetupExtensionsBuilder setupBuilder) | ||
{ | ||
return setupBuilder.RegisterTarget<AppCenterTarget>("AppCenter"); | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/NLog.Targets.AppCenter/Config/SetupLoadConfigurationExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using NLog.Config; | ||
using NLog.Layouts; | ||
using NLog.Targets; | ||
|
||
namespace NLog | ||
{ | ||
/// <summary> | ||
/// Extension methods to setup NLog <see cref="LoggingConfiguration"/> | ||
/// </summary> | ||
public static class SetupLoadConfigurationExtensions | ||
{ | ||
/// <summary> | ||
/// Write to AppCenter NLog Target | ||
/// </summary> | ||
/// <param name="configBuilder"></param> | ||
/// <param name="layout">Override the default Layout for output</param> | ||
/// <param name="appSecret">appsecret for starting AppCenter if needed</param> | ||
/// <param name="reportExceptionAsCrash">activate AppCenter-Crashes and report Exceptions as crashes</param> | ||
public static ISetupConfigurationTargetBuilder WriteToAppCenter(this ISetupConfigurationTargetBuilder configBuilder, Layout layout = null, Layout appSecret = null, bool reportExceptionAsCrash = false) | ||
{ | ||
var logTarget = new AppCenterTarget(); | ||
if (layout != null) | ||
logTarget.Layout = layout; | ||
if (appSecret != null) | ||
logTarget.AppSecret = appSecret; | ||
if (reportExceptionAsCrash) | ||
logTarget.ReportExceptionAsCrash = reportExceptionAsCrash; | ||
return configBuilder.WriteTo(logTarget); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters