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);
                          StartCoroutine(SendData(loggingForm));
                    	}
                    
                        public IEnumerator SendData(WWWForm form){
                          //Send WWW Form to Loggly, replace TOKEN with your unique ID from Loggly
                          WWW sendLog = new WWW("https://logs-01.loggly.com/inputs/TOKEN/tag/Unity3D", form);
                          yield return sendLog;
                        }
                    }
                    

                    Replace:

                    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.

                    tag:Unity3D
                    Unity 3D Example

                    Advanced Options

                    Troubleshooting Unity3D Logs

                    Thanks for the feedback! We'll use it to improve our support documentation.


                    日本熟妇色一本在线视频