How can I efficiently parse log entries that contain pipes and JSON?

0
5
Asked By WanderingCoder123 On

I'm having trouble parsing log files created by one of our vendors. Each log entry has pipes separating different sections, but the challenge is that the JSON data in the logs can also contain pipes. I initially tried splitting the log line by the pipe character, but that led to issues because of the pipes within the JSON.

Currently, I'm parsing line by line and character by character, but it's slow and quite messy. I'm looking for a more efficient way to extract relevant information without getting tangled up in the JSON pipes. Here's an example of what a log entry looks like:

`14.7.1.3918|2025-12-29T09:27:34.871-06|INFO|"CONNECTION GET DEFINITIONS MONITORS" "12345678-174a-3474-aaaa-982011234075"|{ "description": "CONNECTION|GET|DEFINITIONS|MONITORS", "deviceUid": "12345678-174a-3474-aaaa-982011234075", "logContext": "Managed", "logcontext": "Monitoring.Program", "membername": "monitor", "httpStatusCode": 200 }`

I want to separate this log entry into different parts but keep the JSON intact. Any suggestions for a better method?

0 Answers

There is no answer to this question yet. If you know the answer or can offer some help, please use the form below.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.