Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


Log

Logs message to the Unity Console using default logger.
Read time 3 minutesLast updated 5 days ago

Definition

  • Type: Method
  • Namespace: UnityEngine
  • Assembly: UnityEngine.CoreModule

Log(LogType, Object)

Logs
message
to the Unity Console using default logger.
public void Log(LogType logType, object message)

Parameters

logType

The type of the log message.

message

String or object to be converted to string representation for display.

Remarks

Additional Resources: ILogger, ILogHandler.

Examples

using UnityEngine;using System.Collections;public class MyGameClass : MonoBehaviour{ private static ILogger logger = Debug.unityLogger; private static string kTAG = "MyGameTag"; void MyGameMethod() { logger.Log(kTAG, "Hello"); Debug.unityLogger.Log(kTAG, "World"); logger.Log("Hello Logger"); }}

Log(LogType, Object, Object)

Logs
message
to the Unity Console using default logger.
public void Log(LogType logType, object message, Object context)

Parameters

logType

The type of the log message.

message

String or object to be converted to string representation for display.

context

Object to which the message applies.

Remarks

Additional Resources: ILogger, ILogHandler.

Examples

using UnityEngine;using System.Collections;public class MyGameClass : MonoBehaviour{ private static ILogger logger = Debug.unityLogger; private static string kTAG = "MyGameTag"; void MyGameMethod() { logger.Log(kTAG, "Hello"); Debug.unityLogger.Log(kTAG, "World"); logger.Log("Hello Logger"); }}

Log(LogType, string, Object)

Logs
message
to the Unity Console using default logger.
public void Log(LogType logType, string tag, object message)

Parameters

logType

The type of the log message.

Used to identify the source of a log message. It usually identifies the class where the log call occurs.

message

String or object to be converted to string representation for display.

Remarks

Additional Resources: ILogger, ILogHandler.

Examples

using UnityEngine;using System.Collections;public class MyGameClass : MonoBehaviour{ private static ILogger logger = Debug.unityLogger; private static string kTAG = "MyGameTag"; void MyGameMethod() { logger.Log(kTAG, "Hello"); Debug.unityLogger.Log(kTAG, "World"); logger.Log("Hello Logger"); }}

Log(LogType, string, Object, Object)

Logs
message
to the Unity Console using default logger.
public void Log(LogType logType, string tag, object message, Object context)

Parameters

logType

The type of the log message.

Used to identify the source of a log message. It usually identifies the class where the log call occurs.

message

String or object to be converted to string representation for display.

context

Object to which the message applies.

Remarks

Additional Resources: ILogger, ILogHandler.

Examples

using UnityEngine;using System.Collections;public class MyGameClass : MonoBehaviour{ private static ILogger logger = Debug.unityLogger; private static string kTAG = "MyGameTag"; void MyGameMethod() { logger.Log(kTAG, "Hello"); Debug.unityLogger.Log(kTAG, "World"); logger.Log("Hello Logger"); }}

Log(Object)

Logs
message
to the Unity Console using default logger.
public void Log(object message)

Parameters

message

String or object to be converted to string representation for display.

Remarks

Additional Resources: ILogger, ILogHandler.

Examples

using UnityEngine;using System.Collections;public class MyGameClass : MonoBehaviour{ private static ILogger logger = Debug.unityLogger; private static string kTAG = "MyGameTag"; void MyGameMethod() { logger.Log(kTAG, "Hello"); Debug.unityLogger.Log(kTAG, "World"); logger.Log("Hello Logger"); }}

Log(string, Object)

Logs
message
to the Unity Console using default logger.
public void Log(string tag, object message)

Parameters

Used to identify the source of a log message. It usually identifies the class where the log call occurs.

message

String or object to be converted to string representation for display.

Remarks

Additional Resources: ILogger, ILogHandler.

Examples

using UnityEngine;using System.Collections;public class MyGameClass : MonoBehaviour{ private static ILogger logger = Debug.unityLogger; private static string kTAG = "MyGameTag"; void MyGameMethod() { logger.Log(kTAG, "Hello"); Debug.unityLogger.Log(kTAG, "World"); logger.Log("Hello Logger"); }}

Log(string, Object, Object)

Logs
message
to the Unity Console using default logger.
public void Log(string tag, object message, Object context)

Parameters

Used to identify the source of a log message. It usually identifies the class where the log call occurs.

message

String or object to be converted to string representation for display.

context

Object to which the message applies.

Remarks

Additional Resources: ILogger, ILogHandler.

Examples

using UnityEngine;using System.Collections;public class MyGameClass : MonoBehaviour{ private static ILogger logger = Debug.unityLogger; private static string kTAG = "MyGameTag"; void MyGameMethod() { logger.Log(kTAG, "Hello"); Debug.unityLogger.Log(kTAG, "World"); logger.Log("Hello Logger"); }}