Send Logs to Pinghome using NLog (.NET)


This guide shows how to send logs to Pinghome from your .NET application using NLog. You'll use HTTP targets to push logs with structured context like extra, user_id, and any other fields.


๐Ÿงฐ Requirements


  • .NET version 5 or later
  • Pinghome API Token
  • Log Group URL from the Pinghome Dashboard

๐Ÿ“ฆ Install Packages

โš™๏ธ Configure NLog

๐Ÿš€ Log Example

โœ… Sample JSON Output

๐Ÿงช Troubleshooting

IssueSolution
No logs in PinghomeCheck if your token and log group URL are correct.
Invalid layout or JSONEnsure extra is serialized correctly with JsonSerializer.Serialize or proper serialization.
Nothing is sent to HTTPCheck internal-nlog.log for errors.
Config not workingEnsure NLog.config is set to CopyToOutputDirectory.

๐Ÿ“˜ See Also