ElasticSearch Target Null
See original GitHub issueDescribe the bug
When I try to Log data as target old and new
data was store in db is like this
{ "customFields": { "ReferenceId": 12, "UserInfo": { "userId": "055a1227-fc72-4036-b827-1b77dc7c2cdd", "userName": "m.test", "remoteIpAddress": "::1", "localIpAddress": "::1", "osInfo": "Device: Other | Windows Version: 10.", "browserName": "Edge Version: 103.0" } }, "target": { "type": "Guild", "old": [ [ [] ], [ [] ], [ [] ], [ [] ], [ [] ], [ [] ], [ [] ], [ [] ], [ [] ] ], "new": [ [ [] ], [ [] ], [ [] ], [ [] ], [ [] ], [ [] ], [ [] ], [ [] ], [ [] ] ] }, "comments": [ "Guild به روز شد" ], "startDate": "2022-07-17T15:07:28.2990601Z", "endDate": "2022-07-17T15:07:31.8419572Z", "duration": 3543 }, }
my connection string to elastic with audit is this :
Audit.Core.Configuration.DataProvider = new ElasticsearchDataProvider() { ConnectionSettings = new ConnectionSettings(new SingleNodeConnectionPool(new Uri(https://user:pass@es01:9200))) .ConnectionLimit(-1) .ServerCertificateValidationCallback((o, certificate, arg3, arg4) => true), IndexBuilder = ev => ev.EventType.ToLower(), IdBuilder = ev => Guid.NewGuid() };
and my problem was start when i use https and ssl in elastic and use ConnectionSettings like this to bypass invalid certificate
please help to solve this error
my elastic search version : 8.3.2
Target .NET framework:
- .NET Core 6
Issue Analytics
- State:
- Created a year ago
- Comments:6 (4 by maintainers)
Top GitHub Comments
This was fixed on version 19.2.0, please upgrade your references and re-test
I think the problem is in the pre-serialization made to the target object.
Changing this line:
https://github.com/thepirat000/Audit.NET/blob/b590bef777b7e2ba6005f78e49cb04d5407eabdb/src/Audit.NET.ElasticSearch/Providers/ElasticsearchDataProvider.cs#L82
To:
Fixes the issue.
I will run some tests and eventually publish a fixed version of the library.
In the meantime you could override the
Serialize<T>
in a custom data provider inheriting fromElasticsearchDataProvider