Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions src/negative_test/appsettings/serilog-1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"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"
}
}
28 changes: 28 additions & 0 deletions src/negative_test/appsettings/serilog-2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"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": []
}
}
288 changes: 288 additions & 0 deletions src/schemas/json/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,291 @@
"default": "Ignore"
}
}
},
"Serilog": {
"type": "object",
"title": "Serilog appSettings",
"description": "Serilog appSettings Configuration",
"properties": {
"$schema": {
"type": "string",
"title": "Schema",
"description": "Pointer to the schema against which this document should be validated."
},
"Using": {
"type": "array",
"title": "List of Auto-discovery of configuration assemblies",
"description": "Using section contains list of assemblies in which configuration methods. Can be required depending of the project type: See: https://github.com/serilog/serilog-settings-configuration#using-section-and-auto-discovery-of-configuration-assemblies",
"uniqueItems": true,
"items": {
"$ref": "#/definitions/Serilog/definitions/AssemblyReference"
}
},
"LevelSwitches": {
"type": "object",
"patternProperties": {
"^(?<SerilogLevelSwitcherName>\\${0,1}[A-Za-z]+[A-Za-z0-9]*)$": {
"$ref": "#/definitions/Serilog/definitions/SerilogLogEventLevel"
}
},
"additionalProperties": false
},
"FilterSwitches": {
"type": "object",
"patternProperties": {
"^(?<SerilogLevelSwitcherName>\\${0,1}[A-Za-z]+[A-Za-z0-9]*)$": {
"type": "string"
}
},
"additionalProperties": false
},
"MinimumLevel": {
"type": ["string", "object"],
"title": "Minimum LogLevel Threshold",
"description": "Minimum LogLevel Threshold. (Support dynamic reload if the underlying IConfigurationProvider supports it)",
"oneOf": [
{
"$ref": "#/definitions/Serilog/definitions/SerilogLogEventLevel"
},
{
"$ref": "#/definitions/Serilog/definitions/DetailedMinimumLevel"
}
]
},
"Properties": {
"type": "object",
"title": "Log events Properties",
"description": "This section defines a static list of key-value pairs that will enrich log events.",
"additionalProperties": {
"type": "string"
}
},
"Enrich": {
"allOf": [
{
"$ref": "#/definitions/Serilog/definitions/MethodCallReference"
}
],
"title": "Log events Enriches",
"description": "This section defines Enriches that will be applied to log events."
},
"Destructure": {
"allOf": [
{
"$ref": "#/definitions/Serilog/definitions/MethodCallReference"
}
],
"title": "Log events Destructure",
"description": "This section defines Destructure."
},
"Filter": {
"allOf": [
{
"$ref": "#/definitions/Serilog/definitions/MethodCallReference"
}
],
"title": "Log events filters",
"description": "This section defines filters that will be applied to log events."
},
"WriteTo": {
"allOf": [
{
"$ref": "#/definitions/Serilog/definitions/MethodCallReference"
}
],
"title": "Configuration for log destination",
"description": "This section configures the sinks that log events will be emitted to."
},
"AuditTo": {
"allOf": [
{
"$ref": "#/definitions/Serilog/definitions/MethodCallReference"
}
],
"title": "Configuration for log destination for auditing",
"description": "This section configures sinks for auditing, instead of regular (safe) logging. Obs: When auditing is used, exceptions from sinks and any intermediate filters propagate back to the caller."
}
},
"patternProperties": {
"^Enrich:((?<EnvironmentVariableName>[a-zA-Z_]\\w*)|(?<ArrayIndex>\\d*))$": {
"allOf": [
{
"$ref": "#/definitions/Serilog/definitions/MethodCallReferenceItem"
}
],
"title": "Log events Enriches",
"description": "This section defines Enriches that will be applied to log events."
},
"^Destructure:((?<EnvironmentVariableName>[a-zA-Z_]\\w*)|(?<ArrayIndex>\\d*))$": {
"allOf": [
{
"$ref": "#/definitions/Serilog/definitions/MethodCallReferenceItem"
}
],
"title": "Log events Destructure",
"description": "This section defines Destructure."
},
"^Filter:((?<EnvironmentVariableName>[a-zA-Z_]\\w*)|(?<ArrayIndex>\\d*))$": {
"allOf": [
{
"$ref": "#/definitions/Serilog/definitions/MethodCallReferenceItem"
}
],
"title": "Log events filters",
"description": "This section defines filters that will be applied to log events."
},
"^WriteTo:((?<EnvironmentVariableName>[a-zA-Z_]\\w*)|(?<ArrayIndex>\\d*))$": {
"allOf": [
{
"$ref": "#/definitions/Serilog/definitions/MethodCallReferenceItem"
}
],
"title": "Configuration for log destination",
"description": "This section configures the sinks that log events will be emitted to."
},
"^AuditTo:((?<EnvironmentVariableName>[a-zA-Z_]\\w*)|(?<ArrayIndex>\\d*))$": {
"allOf": [
{
"$ref": "#/definitions/Serilog/definitions/MethodCallReferenceItem"
}
],
"title": "Configuration for log destination for auditing",
"description": "This section configures sinks for auditing, instead of regular (safe) logging. Obs: When auditing is used, exceptions from sinks and any intermediate filters propagate back to the caller."
}
},
"additionalProperties": false,
"definitions": {
"SerilogLogEventLevel": {
"type": "string",
"title": "Log level",
"description": "Log level threshold.",
"enum": [
"Verbose",
"Debug",
"Information",
"Warning",
"Error",
"Fatal"
]
},
"LoggingLevelSwitch": {
"type": "string",
"title": "LevelSwitches name",
"description": "Log Level Switch string reference.",
"pattern": "^(?<SerilogLevelSwitcherName>\\${0,1}[A-Za-z]+[A-Za-z0-9]*)$"
},
"SerilogLogLevelThreshold": {
"type": "string",
"title": "Log Level or LevelSwitches name",
"description": "A Serilog Log Level or a reference to a Log Level Switch name on `LevelSwitches` configuration.",
"anyOf": [
{
"$ref": "#/definitions/Serilog/definitions/SerilogLogEventLevel"
},
{
"$ref": "#/definitions/Serilog/definitions/LoggingLevelSwitch"
}
]
},
"DetailedMinimumLevel": {
"type": "object",
"title": "Detailed Log level.",
"description": "Detailed Log level threshold object. Allowing set log levels be overridden per logging source.",
"properties": {
"Default": {
"$ref": "#/definitions/Serilog/definitions/SerilogLogLevelThreshold"
},
"ControlledBy": {
"$ref": "#/definitions/Serilog/definitions/LoggingLevelSwitch"
},
"Override": {
"type": "object",
"title": "Logging Source Log level object.",
"description": "Set the Log level threshold or LevelSwitcher reference per Logging Source.",
"additionalProperties": {
"$ref": "#/definitions/Serilog/definitions/SerilogLogLevelThreshold"
}
}
},
"additionalProperties": false
},
"AssemblyReference": {
"type": "string",
"title": "Assembly Name",
"description": ".NET Assembly Name, without the file extension",
"minLength": 1,
"pattern": "^(?<AssemblyName>\\S+)$"
},
"ComplexMethodCallReference": {
"type": "object",
"properties": {
"Name": {
"$ref": "#/definitions/Serilog/definitions/CSharpMethodName"
},
"Args": {
"type": "object",
"patternProperties": {
"^(?<CSharpMethodArgumentName>[a-zA-Z_]\\w*)$": {}
},
"additionalProperties": false
}
},
"additionalProperties": false,
"required": ["Name"]
},
"MethodCallReferenceItem": {
"type": ["string", "object"],
"oneOf": [
{
"$ref": "#/definitions/Serilog/definitions/CSharpMethodName"
},
{
"$ref": "#/definitions/Serilog/definitions/ComplexMethodCallReference"
}
]
},
"MethodCallReference": {
"type": ["array", "string", "object"],
"minLength": 1,
"pattern": "^(?<CSharpMethodName>[a-zA-Z_]\\w*)$",
"minItems": 1,
"uniqueItems": true,
"items": {
"$ref": "#/definitions/Serilog/definitions/MethodCallReferenceItem"
},
"additionalProperties": {
"$ref": "#/definitions/Serilog/definitions/MethodCallReferenceItem"
}
},
"CSharpMethodName": {
"type": "string",
"title": "Method Name",
"description": "A name referring to a C# Class method",
"minLength": 1,
"pattern": "^(?<CSharpMethodName>[a-zA-Z_]\\w*)$"
},
"CSharpMethodArgumentName": {
"type": "string",
"title": "Argument Name",
"description": "A name referring to a C# Class method argument",
"minLength": 1,
"pattern": "^(?<CSharpMethodArgumentName>[a-zA-Z_]\\w*)$"
},
"EnvironmentVariableName": {
"type": "string",
"title": "Environment Variable Name",
"description": "A name referring to a OS Environment Variable",
"minLength": 1,
"pattern": "^(?<EnvironmentVariableName>[a-zA-Z_]\\w*)$"
},
"SerilogLevelSwitcherName": {
"type": "string",
"title": "A Level Switcher Name",
"description": "A name referring to a Serilog Settings Configuration Level Switcher",
"minLength": 1,
"pattern": "^(?<SerilogLevelSwitcherName>\\${0,1}[A-Za-z]+[A-Za-z0-9]*)$"
}
}
}
},
"id": "https://json.schemastore.org/appsettings.json",
Expand All @@ -675,6 +960,9 @@
},
"^(nlog|Nlog|NLog)$": {
"$ref": "#/definitions/NLog"
},
"^(Serilog|serilog)$": {
"$ref": "#/definitions/Serilog"
}
},
"properties": {
Expand Down
Loading