Documentation forLoggly

Send Unity 3D logs to Loggly

You can send your Unity3D logs to loggly via HTTP/HTTPS endpoints using the Unity Engine Log to Loggly package. We offer an example showing how to send logs to Loggly.

Unity has several networking classes, but the most straightforward way to send logs from Unity is to combine the WWWForm class. The WWWForm class allows you to build JSON-like messages which you can then send with the WWW class, which Loggly is able to parse as JSON.

Unity 3D Logging Setup

1. Configure Unity3D

Open your Unity editor and create a new C# script LogOutputHandler.cs in your scripts folder and paste the following code in the file. Alternatively you can use the JavaScript version.

using UnityEngine;
using System.Collections;

public class LogOutputHandler : MonoBehaviour {

  //Register the HandleLog function on scene start to fire on debug.log events
  public void OnEnable(){
    Application.logMessageReceived += HandleLog;

  //Remove callback when object goes out of scope
  public void OnDisable(){
    Application.logMessageReceived -= HandleLog;

  //Create a string to store log level in
  string level = "";

  //Capture debug.log output, send logs to Loggly
  public void HandleLog(string logString, string stackTrace, LogType type) {

    //Initialize WWWForm and store log level as a string
    level = type.ToString ();
    var loggingForm = new WWWForm();

    //Add log message to WWWForm
    loggingForm.AddField("LEVEL", level);
    loggingForm.AddField("Message", logString);
    loggingForm.AddField("Stack_Trace", stackTrace);

    //Add any User, Game, or Device MetaData that would be useful to finding issues later
    loggingForm.AddField("Device_Model", SystemInfo.deviceModel);

  public IEnumerator SendData(WWWForm form){
    //Send WWW Form to Loggly, replace TOKEN with your unique ID from Loggly
    WWW sendLog = new WWW("", form);
    yield return sendLog;


In above code, Unity makes the Debug.Log() function available. It normally sends a log message and the program scope where the log was fired from to the Unity console and the Application.RegisterLogCallback() function allows you to capture this output and send it to Loggly.

2. Send logs to Loggly

Create a new C# script LogglyTest.cs for the same program scope and paste the following code in it

using UnityEngine;
using System.Collections;
public class LogglyTest : MonoBehaviour {
  void Start () {
    Debug.Log ("Hello world");

Now run your Unity application.

3. Verify Events

Search Loggly for the events with tag as Unity3D over the past hour. It may take few minutes to index the event. If if doesn’t work, see the troubleshooting section below.


Unity 3D Example

Advanced Options

Troubleshooting Unity3D Logs

When the APM Integrated Experience is enabled, Loggly shares a common navigation and enhanced feature set with the other integrated experiences' products. How you navigate the product and access its features may vary from these instructions. For more information, go to the APM Integrated Experience documentation.

The scripts are not supported under any SolarWinds support program or service. The scripts are provided AS IS without warranty of any kind. SolarWinds further disclaims all warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The risk arising out of the use or performance of the scripts and documentation stays with you. In no event shall SolarWinds or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the scripts or documentation.