diff --git a/src/BootstrapBlazor.Shared/Locales/en.json b/src/BootstrapBlazor.Shared/Locales/en.json
index de3c24bac..9e7431d17 100644
--- a/src/BootstrapBlazor.Shared/Locales/en.json
+++ b/src/BootstrapBlazor.Shared/Locales/en.json
@@ -390,6 +390,19 @@
"ToastText": "Toast",
"TimerText": "Timer"
},
+ "BootstrapBlazor.Shared.Pages.GlobalException": {
+ "Title": "Global exception",
+ "P1": "Added component BlazorLogger
Through this component, global logs and exceptions can be output uniformly; currently, the Blazor
framework does not provide a MVC
like < b>Global exception The overall solution, for the time being, you need to use try/catch
in the code block for exception capture",
+ "H1": "Instructions",
+ "P2": "1. Add AddLogging
to the Startup
file to enable the net core
system log function",
+ "P3": "2. Use BlazorLogger
to wrap the content, such as: Body
in MainLayout
",
+ "P4": "3. Use cascading parameters in the code to get examples",
+ "P5": "4. Console or IIS output visible log information",
+ "Block1Title": "Test",
+ "Block1Intro": "This function is to obtain the component instance through the cascade parameter and use its function",
+ "P6": "In this example code, an error code that divides by zero is written. Because try/catch
is used to capture the exception, the error message is displayed in the console below",
+ "ButtonText": "test"
+ },
"BootstrapBlazor.Shared.Pages.Components.Block": {
"Title": "",
"SubTitle": "Demo"
diff --git a/src/BootstrapBlazor.Shared/Locales/zh.json b/src/BootstrapBlazor.Shared/Locales/zh.json
index c427ff7fe..730f55c48 100644
--- a/src/BootstrapBlazor.Shared/Locales/zh.json
+++ b/src/BootstrapBlazor.Shared/Locales/zh.json
@@ -97,10 +97,6 @@
"P9": "不显示标签
ShowLabel='false'
,组件内的所有表单组件 不显示 标签form-inline
,组件内的所有表单组件标签前置BlazorLogger
通过本组件可以对全局的日志、异常进行统一输出;目前由于 Blazor
框架并未提供一个类似 MVC
的 全局异常 整体解决方案,暂时还需要在代码块中使用 try/catch
进行异常捕获",
+ "H1": "使用方法",
+ "P2": "1. Startup
文件中增加 AddLogging
开启 net core
系统日志功能",
+ "P3": "2. 使用 BlazorLogger
对内容进行包裹,如:MainLayout
中对 Body
使用",
+ "P4": "3. 代码中使用级联参数获取实例",
+ "P5": "4. 控制台或者 IIS 输出可见日志信息",
+ "Block1Title": "测试",
+ "Block1Intro": "本功能是通过级联参数获取到组件实例并使用其功能",
+ "P6": "本例代码中写了一个除以零的错误代码,由于使用了 try/catch
对异常进行了捕获,将错误信息显示到下面控制台中",
+ "ButtonText": "测试"
+ },
+ "BootstrapBlazor.Shared.Pages.Components.Block": {
+ "Title": "未设置",
+ "SubTitle": "示例"
+ },
"BootstrapBlazor.Shared.Pages.Components.Tips": {
"Title": "小提示"
},
diff --git a/src/BootstrapBlazor.Shared/Pages/Samples/GlobalException.razor b/src/BootstrapBlazor.Shared/Pages/Samples/GlobalException.razor
index f8214ed6f..4e5c46bca 100644
--- a/src/BootstrapBlazor.Shared/Pages/Samples/GlobalException.razor
+++ b/src/BootstrapBlazor.Shared/Pages/Samples/GlobalException.razor
@@ -1,26 +1,27 @@
@page "/globalexception"
@layout ComponentLayout
+@inject IStringLocalizer增加组件 BlazorLogger
通过本组件可以对全局的日志、异常进行统一输出;目前由于 Blazor
框架并未提供一个类似 MVC
的 全局异常 整体解决方案,暂时还需要在代码块中使用 try/catch
进行异常捕获
@((MarkupString)Localizer["P1"].Value)
-1. Startup
文件中增加 AddLogging
开启 net core
系统日志功能
@((MarkupString)Localizer["P2"].Value)
public void ConfigureServices(IServiceCollection services) { services.AddLogging(builder => builder.AddConsole()); }-
2. 使用 BlazorLogger
对内容进行包裹,如:MainLayout
中对 Body
使用
@((MarkupString)Localizer["P3"].Value)
<BlazorLogger> @@Body </BlazorLogger>-
3. 代码中使用级联参数获取实例
+@((MarkupString)Localizer["P4"].Value)
[CascadingParameter] [NotNull] @@ -39,7 +40,7 @@ private void OnClick() } }-
4. 控制台或者 IIS 输出可见日志信息
+@((MarkupString)Localizer["P5"].Value)
crit: BootstrapBlazor.Components.BlazorLogger[0] TimeStamp: 8/23/2021 12:20:46 PM MachineName: ECS-A399 @@ -57,8 +58,8 @@ private void OnClick() System.DivideByZeroException: Attempted to divide by zero. at BootstrapBlazor.Shared.Pages.GlobalException.OnClick() in D:\Argo\src\BB\BootstrapBlazor\src\BootstrapBlazor.Shared\Pages\GlobalException.razor.cs:line 30-
本例代码中写了一个除以零的错误代码,由于使用了 try/catch
对异常进行了捕获,将错误信息显示到下面控制台中
@((MarkupString)Localizer["P6"].Value)
+