Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
BailunTrace
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
wms
BailunTrace
Commits
ffde33dd
Commit
ffde33dd
authored
Apr 09, 2020
by
huangzhihong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新文档
parent
6389849b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
13 deletions
+49
-13
README.md
README.md
+4
-2
README.md
doc/README.md
+42
-2
Program.cs
samples/SimpleConsole/Program.cs
+3
-9
No files found.
README.md
View file @
ffde33dd
# 日志使用
> [详细配置说明](/doc/README.md)
## 一、 配置
1.
Program.cs
...
...
@@ -15,7 +17,7 @@
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.Use
Serilog(true, true);//注入 SerilogFactory
.Use
BailunTrace(true, true);//引用日志与APM相关组件
}
```
...
...
@@ -26,7 +28,7 @@
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory, IApiInfo apiInfo)
{
app.Use
SerilogTrace
Logging(); //使用日志跟踪中间件,注意顺序,必须是第一个
app.Use
BailunRequest
Logging(); //使用日志跟踪中间件,注意顺序,必须是第一个
app.UseAbpService(_appConfiguration, loggerFactory, apiInfo);
}
```
...
...
doc/README.md
View file @
ffde33dd
...
...
@@ -9,7 +9,7 @@
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory, IApiInfo apiInfo)
{
app.Use
SerilogTrace
Logging(); //使用日志跟踪中间件,注意顺序,必须是第一个
app.Use
BailunRequest
Logging(); //使用日志跟踪中间件,注意顺序,必须是第一个
app.UseAbpService(_appConfiguration, loggerFactory, apiInfo);
}
```
...
...
@@ -26,7 +26,7 @@
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.Use
Serilog(true, true);//注入 SerilogFactory
.Use
BailunTrace(true, true); //引用日志与APM相关组件
}
```
...
...
@@ -34,6 +34,46 @@
1.
**Console**
配置
-
`Program.cs`
``` C#
class Program
{
static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
static IHostBuilder CreateHostBuilder(string[] args) =>
new HostBuilder()
.UseContentRoot(Directory.GetCurrentDirectory())
.ConfigureHostConfiguration(config =>
{
config.AddEnvironmentVariables(prefix: "DOTNET_");
if (args != null)
{
config.AddCommandLine(args);
}
})
.ConfigureAppConfiguration((hostingContext, config) =>
{
var env = hostingContext.HostingEnvironment;
config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true);
})
.ConfigureServices(services =>
{
services.AddHostedService<Worker>();
services.AddHttpApi<IUserApi>(opt =>
{
opt.HttpHost = new Uri("http://localhost:5000/");
});
})
.UseBailunTrace(true, true);//引用日志与APM相关组件
}
```
1.
**appsettings.json**
...
...
samples/SimpleConsole/Program.cs
View file @
ffde33dd
...
...
@@ -20,15 +20,10 @@ namespace SimpleConsole
{
static
void
Main
(
string
[]
args
)
{
var
host
=
CreateHost
(
args
);
Log
.
Information
(
"Getting the motors running..."
);
host
.
Run
();
CreateHostBuilder
(
args
).
Build
().
Run
();
}
static
IHost
CreateHost
(
string
[]
args
)
=>
static
IHost
Builder
CreateHostBuilder
(
string
[]
args
)
=>
new
HostBuilder
()
.
UseContentRoot
(
Directory
.
GetCurrentDirectory
())
.
ConfigureHostConfiguration
(
config
=>
...
...
@@ -55,8 +50,7 @@ namespace SimpleConsole
opt
.
HttpHost
=
new
Uri
(
"http://localhost:5000/"
);
});
})
.
UseBailunTrace
(
true
,
true
)
.
Build
();
.
UseBailunTrace
(
true
,
true
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment