Skip to content

Removing certain fields from LogEvent #58

@tessierp

Description

@tessierp

I would like to know if there is a way to filter out certain fields from what is written in LogEvent. My current configuration is as follow


  {
	"Name": "PostgreSQL",
	"Args": {
	  "connectionString": "DevPostgreSQL",
	  "tableName": "Logs",
	  "schemaName": "log",
	  "needAutoCreateTable": true,
	  "needAutoCreateSchema": true,
	  "loggerColumnOptions": {
		"Id": "IdAutoIncrement",
		"Level": "LevelAsText",
		"TimeStamp": "Timestamp",
		"LogEvent": "LogEvent",
		"MessageTemplate": "Message"
	  },
	  "loggerPropertyColumnOptions": {
		"Application": {
		  "Name": "Application",
		  "Format": "{0}",
		  "WriteMethod": "Raw",
		  "DbType": "Text"
		},
		"LogType": {
		  "Name": "LogType",
		  "Format": "{0}",
		  "WriteMethod": "Raw",
		  "DbType": "Text"
		}
	  }
	}
  }

Which produces the current output in LogEvent :

{
  "Level": "Error",
  "Timestamp": "2023-03-24T12:25:31.3008171-04:00",
  "Properties": {
    "LogType": "Log",
    "Application": "WeatherApp",
    "ExceptionLog": {
      "StackTrace": "   at WebApplication1.Controllers.WeatherForecastController.Exception() in F:\\Users\\someone\\Projects\\Technology\\Coding\\DotNet\\MyProjects\\WebApplication1\\WebApplication1\\Controllers\\WeatherForecastController.cs:line 50",
      "ExceptionMessage": "Logging SystemException for testing purposes.",
      "InnerExceptionMessage": ""
    }
  },
  "MessageTemplate": "{@ExceptionLog}"
}

What I would like is to filter out everything except the content of the Message to produce something like this :

{
    "Properties": {
        "ExceptionLog": {
            "ExceptionMessage": "Logging SystemException for testing purposes.",
            "InnerExceptionMessage": "",
            "StackTrace": "   at WebApplication1.Controllers.WeatherForecastController.Exception() in F:\\Users\\someone\\Projects\\Technology\\Coding\\DotNet\\MyProjects\\WebApplication1\\WebApplication1\\Controllers\\WeatherForecastController.cs:line 50"
        }
    }
}

I was experimenting with the MSSQL Sink which is able to achieve this by configuring these parameters :

"logEvent": {
  "excludeAdditionalProperties": false,
  "excludeStandardColumns": false
},

Is there a way to achieve the same result with PostgreSQL Alternative's Sink? The reason is, all the data can be found in other columns and it would allow me to reduce the size of the data which could add up over time.

Thanks

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions