File tree Expand file tree Collapse file tree 3 files changed +37
-11
lines changed Expand file tree Collapse file tree 3 files changed +37
-11
lines changed Original file line number Diff line number Diff line change 11using System ;
2+ using System . IO ;
23using System . Linq ;
34using System . Threading . Tasks ;
5+ using Microsoft . Extensions . Configuration ;
6+ using Microsoft . Extensions . Logging ;
47using Notion . Client ;
58
69namespace list_users
@@ -14,6 +17,19 @@ static async Task Main(string[] args)
1417 AuthToken = "<Token>"
1518 } ) ;
1619
20+ var configuration = new ConfigurationBuilder ( )
21+ . AddJsonFile ( Directory . GetCurrentDirectory ( ) + "/appsettings.json" )
22+ . Build ( ) ;
23+
24+ var factory = LoggerFactory . Create ( builder =>
25+ {
26+ builder . ClearProviders ( ) ;
27+ builder . AddConfiguration ( configuration . GetSection ( "Logging" ) ) ;
28+ builder . AddConsole ( ) ;
29+ } ) ;
30+
31+ NotionLogging . ConfigureLogger ( factory ) ;
32+
1733 var usersList = await client . Users . ListAsync ( ) ;
1834
1935 Console . WriteLine ( usersList . Results . Count ( ) ) ;
Original file line number Diff line number Diff line change 1+ {
2+ "Logging" : {
3+ "LogLevel" : {
4+ "Default" : " Information"
5+ }
6+ }
7+ }
Original file line number Diff line number Diff line change 11<Project Sdk =" Microsoft.NET.Sdk" >
2-
3- <PropertyGroup >
4- <OutputType >Exe</OutputType >
5- <TargetFramework >net5.0</TargetFramework >
6- <RootNamespace >list_users</RootNamespace >
7- </PropertyGroup >
8-
9- <ItemGroup >
10- <PackageReference Include =" Notion.Net" Version =" 1.0.4" />
11- </ItemGroup >
12-
2+ <PropertyGroup >
3+ <OutputType >Exe</OutputType >
4+ <TargetFramework >net5.0</TargetFramework >
5+ <RootNamespace >list_users</RootNamespace >
6+ </PropertyGroup >
7+ <ItemGroup >
8+ <!-- <PackageReference Include="Notion.Net" Version="1.0.4"/> -->
9+ <ProjectReference Include =" ..\..\Src\Notion.Client\Notion.Client.csproj" />
10+ </ItemGroup >
11+ <ItemGroup >
12+ <PackageReference Include =" Microsoft.Extensions.Logging" Version =" 5.0.0" />
13+ <PackageReference Include =" Microsoft.Extensions.Logging.Console" Version =" 5.0.0" />
14+ <PackageReference Include =" Microsoft.Extensions.Configuration.Json" Version =" 5.0.0" />
15+ </ItemGroup >
1316</Project >
You can’t perform that action at this time.
0 commit comments