diff --git a/serilog-settings-configuration.sln b/serilog-settings-configuration.sln index f0209fd..583e0b5 100644 --- a/serilog-settings-configuration.sln +++ b/serilog-settings-configuration.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29709.97 +# Visual Studio Version 17 +VisualStudioVersion = 17.8.34302.71 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{4E41FD57-5FAB-4E3C-B16E-463DE98338BC}" EndProject @@ -13,11 +13,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "assets", "assets", "{62D0B9 Build.ps1 = Build.ps1 CHANGES.md = CHANGES.md Directory.Build.props = Directory.Build.props + global.json = global.json assets\icon.png = assets\icon.png LICENSE = LICENSE README.md = README.md serilog-settings-configuration.sln.DotSettings = serilog-settings-configuration.sln.DotSettings - global.json = global.json EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{D551DCB0-7771-4D01-BEBD-F7B57D1CF0E3}" @@ -32,7 +32,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sample", "sample\Sample\Sam EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestDummies", "test\TestDummies\TestDummies.csproj", "{B7CF5068-DD19-4868-A268-5280BDE90361}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestApp", "test\TestApp\TestApp.csproj", "{1B6E08F3-16C9-4912-BEEE-57DB78C92A12}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestApp", "test\TestApp\TestApp.csproj", "{1B6E08F3-16C9-4912-BEEE-57DB78C92A12}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JsonShema.Playground", "test\JsonShema.Playground\JsonShema.Playground.csproj", "{3137E063-8AB6-4380-B246-AFA8AE28E26E}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -58,6 +60,10 @@ Global {B7CF5068-DD19-4868-A268-5280BDE90361}.Release|Any CPU.Build.0 = Release|Any CPU {1B6E08F3-16C9-4912-BEEE-57DB78C92A12}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1B6E08F3-16C9-4912-BEEE-57DB78C92A12}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3137E063-8AB6-4380-B246-AFA8AE28E26E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3137E063-8AB6-4380-B246-AFA8AE28E26E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3137E063-8AB6-4380-B246-AFA8AE28E26E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3137E063-8AB6-4380-B246-AFA8AE28E26E}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -68,6 +74,7 @@ Global {A00E5E32-54F9-401A-BBA1-2F6FCB6366CD} = {D24872B9-57F3-42A7-BC8D-F9DA222FCE1B} {B7CF5068-DD19-4868-A268-5280BDE90361} = {D551DCB0-7771-4D01-BEBD-F7B57D1CF0E3} {1B6E08F3-16C9-4912-BEEE-57DB78C92A12} = {D551DCB0-7771-4D01-BEBD-F7B57D1CF0E3} + {3137E063-8AB6-4380-B246-AFA8AE28E26E} = {D551DCB0-7771-4D01-BEBD-F7B57D1CF0E3} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {485F8843-42D7-4267-B5FB-20FE9181DEE9} diff --git a/test/JsonShema.Playground/Invalid/appsettings.serilog.1.json b/test/JsonShema.Playground/Invalid/appsettings.serilog.1.json new file mode 100644 index 0000000..4357090 --- /dev/null +++ b/test/JsonShema.Playground/Invalid/appsettings.serilog.1.json @@ -0,0 +1,46 @@ +{ + "$schema": "../appsettings.schema.json", + + "Serilog": { + + "Using": "Serilog.Sinks.Console", + "MinimumLevel": "a", + "WriteTo": [ + { "x": "Console" }, + { + "Name": 2, + "Args": "" + } + ], + "Enrich": [ + [ "FromLogContext" ], + { "WithMachineName": -1 }, + { "Bad": { "WithThreadId": null } } + ], + "Destructure": [ + { + "Name": "With", + "Ar": { "policy": "Sample.CustomPolicy, Sample" } + }, + { + "Name": "!ToMaximumDepth", + "Ar qs": { "maximumDestructuringDepth": 4 } + }, + { + "Name": "1ToMaximumStringLength", + "Args": { "maximumStringLength": 100 } + }, + { + "Name": "#ToMaximumCollectionCount", + "Args": { "maximumCollectionCount": 10 } + } + ], + "Properties": [ + { + "Application": "Sample" + } + ], + + "NotValid": "Test" + } +} diff --git a/test/JsonShema.Playground/Invalid/appsettings.serilog.2.json b/test/JsonShema.Playground/Invalid/appsettings.serilog.2.json new file mode 100644 index 0000000..0c3f6c6 --- /dev/null +++ b/test/JsonShema.Playground/Invalid/appsettings.serilog.2.json @@ -0,0 +1,31 @@ +{ + "$schema": "../appsettings.schema.json", + + "Serilog": { + "Using": [ "" ], + "LevelSwitches": { "1controlSwitch": "Bad" }, + "FilterSwitches": { "_$filterSwitch": "" }, + + "MinimumLevel": { + "Default": 0, + "Override": { + "Microsoft": [""], + "MyApp.Something.Tricky": "None" + } + }, + "WriteTo:Sublogger": { + "Name1": "Logger", + "2Args": { } + }, + "WriteTo:$": { + "Name": "Async" + }, + "WriteTo:ConditionalSink": { + "Conditional" : null + }, + + "Filter": {}, + "Extra": [] + } + +} diff --git a/test/JsonShema.Playground/JsonShema.Playground.csproj b/test/JsonShema.Playground/JsonShema.Playground.csproj new file mode 100644 index 0000000..27ac386 --- /dev/null +++ b/test/JsonShema.Playground/JsonShema.Playground.csproj @@ -0,0 +1,9 @@ + + + + net6.0 + enable + enable + + + diff --git a/test/JsonShema.Playground/Valid/appsettings.serilog.1.json b/test/JsonShema.Playground/Valid/appsettings.serilog.1.json new file mode 100644 index 0000000..38f60a1 --- /dev/null +++ b/test/JsonShema.Playground/Valid/appsettings.serilog.1.json @@ -0,0 +1,38 @@ +{ + "$schema": "../appsettings.schema.json", + + "Serilog": { + "Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.File" ], + "MinimumLevel": "Debug", + "WriteTo": [ + { "Name": "Console" }, + { + "Name": "File", + "Args": { "path": "Logs/log.txt" } + } + ], + "Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ], + "Destructure": [ + { + "Name": "With", + "Args": { "policy": "Sample.CustomPolicy, Sample" } + }, + { + "Name": "ToMaximumDepth", + "Args": { "maximumDestructuringDepth": 4 } + }, + { + "Name": "ToMaximumStringLength", + "Args": { "maximumStringLength": 100 } + }, + { + "Name": "ToMaximumCollectionCount", + "Args": { "maximumCollectionCount": 10 } + } + ], + "Properties": { + "Application": "Sample" + } + } + +} diff --git a/test/JsonShema.Playground/Valid/appsettings.serilog.2.json b/test/JsonShema.Playground/Valid/appsettings.serilog.2.json new file mode 100644 index 0000000..587e160 --- /dev/null +++ b/test/JsonShema.Playground/Valid/appsettings.serilog.2.json @@ -0,0 +1,127 @@ +{ + "$schema": "../appsettings.schema.json", + + "Serilog": { + "Using": [ "Serilog.Sinks.Console" ], + "LevelSwitches": { "controlSwitch": "Verbose" }, + "FilterSwitches": { "$filterSwitch": "Application = 'Sample'" }, + + "MinimumLevel": { + "Default": "Debug", + "Override": { + "Microsoft": "Warning", + "MyApp.Something.Tricky": "Verbose" + } + }, + "WriteTo:Sublogger": { + "Name": "Logger", + "Args": { + "configureLogger": { + "MinimumLevel": "Verbose", + "WriteTo": [ + { + "Name": "Console", + "Args": { + "outputTemplate": "[{Timestamp:HH:mm:ss} {SourceContext} [{Level}] {Message}{NewLine}{Exception}", + "theme": "Serilog.Sinks.SystemConsole.Themes.SystemConsoleTheme::Grayscale, Serilog.Sinks.Console" + } + } + ] + }, + "restrictedToMinimumLevel": "Verbose", + "levelSwitch": "$controlSwitch" + } + }, + "WriteTo:Async": { + "Name": "Async", + "Args": { + "configure": [ + { + "Name": "File", + "Args": { + "path": "%TEMP%/Logs/serilog-configuration-sample.txt", + "outputTemplate": "{Timestamp:o} [{Level:u3}] ({Application}/{MachineName}/{ThreadId}/{ThreadName}) {Message}{NewLine}{Exception}" + } + } + ] + } + }, + "WriteTo:ConditionalSink": { + "Name": "Conditional", + "Args": { + "expression": "@Level in ['Error', 'Fatal']", + "configureSink": [ + { + "Name": "File", + "Args": { + "path": "%TEMP%/Logs/serilog-configuration-sample-errors.txt", + "formatter": { + "type": "Serilog.Formatting.Compact.CompactJsonFormatter, Serilog.Formatting.Compact", + "valueFormatter": { + "typeTagName": "customTypeTag" + } + } + } + } + ] + } + }, + "Enrich": [ + "FromLogContext", + "WithThreadId", + { + "Name": "AtLevel", + "Args": { + "enrichFromLevel": "Error", + "configureEnricher": [ "WithThreadName" ] + } + }, + { + "Name": "When", + "Args": { + "expression": "Application = 'Sample'", + "configureEnricher": [ "WithMachineName" ] + } + } + ], + "Properties": { + "Application": "Sample" + }, + "Destructure": [ + { + "Name": "With", + "Args": { "policy": "Sample.CustomPolicy, Sample" } + }, + { + "Name": "ToMaximumDepth", + "Args": { "maximumDestructuringDepth": 3 } + }, + { + "Name": "ToMaximumStringLength", + "Args": { "maximumStringLength": 10 } + }, + { + "Name": "ToMaximumCollectionCount", + "Args": { "maximumCollectionCount": 5 } + } + ], + "Filter": [ + { + "Name": "ControlledBy", + "Args": { + "switch": "$filterSwitch" + } + }, + { + "Name": "With", + "Args": { + "filter": { + "type": "Sample.CustomFilter, Sample", + "levelFilter": "Verbose" + } + } + } + ] + } + +} diff --git a/test/JsonShema.Playground/Valid/appsettings.serilog.3.json b/test/JsonShema.Playground/Valid/appsettings.serilog.3.json new file mode 100644 index 0000000..2340a44 --- /dev/null +++ b/test/JsonShema.Playground/Valid/appsettings.serilog.3.json @@ -0,0 +1,29 @@ +{ + "$schema": "../appsettings.schema.json", + + "Serilog": { + + "Using": [ "Serilog" ], + + "LevelSwitches": { "controlSwitch": "Warning" }, + "FilterSwitches": { "$filterSwitch": "Application = 'Sample'" }, + + "MinimumLevel": { + "Default": "controlSwitch", + "Override": { + "Microsoft": "Warning", + "MyApp.Something.Tricky": "Verbose" + } + }, + + "Enrich": [ + "FromLogContext", + "WithThreadId" + ], + + "Properties": { "s": "as" }, + + "WriteTo": [ "Console" ] + + } +} diff --git a/test/JsonShema.Playground/appsettings.schema.json b/test/JsonShema.Playground/appsettings.schema.json new file mode 100644 index 0000000..cdbe9e7 --- /dev/null +++ b/test/JsonShema.Playground/appsettings.schema.json @@ -0,0 +1,997 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "definitions": { + "webOptimizer": { + "title": "web optimizer", + "type": "object", + "description": "Settings for WebOptimizer.Core", + "properties": { + "enableCaching": { + "description": "Determines if the \"cache-control\" HTTP headers should be set and if conditional GET (304) requests should be supported. This could be helpful to disable while in development mode.", + "type": "boolean" + }, + "enableTagHelperBundling": { + "description": "Determines if `