# LogWarning

> A variant of Logger.Log that logs an warning message.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.7/script-reference/unityengine.md)
* **Assembly:** UnityEngine.CoreModule

## LogWarning(string, Object)

A variant of [Logger.Log](/engine/6000.7/script-reference/unityengine/logger/log.md) that logs an warning message.

```csharp
public void LogWarning(string tag, object message)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Used to identify the source of a log message. It usually identifies the class where the log call occurs.**** (\[Object]\(https\://learn.microsoft.com/dotnet/api/system.object)): String or object to be converted to string representation for display.

### Examples

```csharp
using UnityEngine;
using System.Collections;

public class MyGameClass : MonoBehaviour
{
    private static ILogger logger = Debug.unityLogger;
    private static string kTAG = "MyGameTag";
    private Transform tr;

    void MyGameMethod()
    {
        if (tr == null)
        {
            logger.LogWarning(kTAG, "memberVariable must be set to point to a Transform.", tr);

            Debug.unityLogger.LogWarning(kTAG, "Failed! to set Transform",  tr);
        }
    }
}
```

## LogWarning(string, Object, Object)

A variant of [Logger.Log](/engine/6000.7/script-reference/unityengine/logger/log.md) that logs an warning message.

```csharp
public void LogWarning(string tag, object message, Object context)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Used to identify the source of a log message. It usually identifies the class where the log call occurs.**** (\[Object]\(https\://learn.microsoft.com/dotnet/api/system.object)): String or object to be converted to string representation for display.**** (\[Object]\(/engine/6000.7/script-reference/unityengine/object)): Object to which the message applies.

### Examples

```csharp
using UnityEngine;
using System.Collections;

public class MyGameClass : MonoBehaviour
{
    private static ILogger logger = Debug.unityLogger;
    private static string kTAG = "MyGameTag";
    private Transform tr;

    void MyGameMethod()
    {
        if (tr == null)
        {
            logger.LogWarning(kTAG, "memberVariable must be set to point to a Transform.", tr);

            Debug.unityLogger.LogWarning(kTAG, "Failed! to set Transform",  tr);
        }
    }
}
```
