Changing The Time Format

The code below demonstrates how to change the date format of the logs in your Unity project using the CatLog library. By modifying the DateFormat property of the Log.Settings class, you can specify the desired date format for all logs. In this example, the date format is set to "MM/dd/yyyy hh:mm:ss tt".

It is important to note that the date format string should be a valid string that follows the standard date and time format strings in .NET. For more information on these format strings, you can refer to the official Microsoft documentation. Also note that this is only active in builds, and not in the editor, because the time is already included in the editor by default.

using UnityEngine;
using CatLog;

public class CustomLogBehaviour : MonoBehaviour
{
    private void Start()
    {
        // Modify the DateFormat property to change the date format of all logs
        Log.Settings.DateFormat = "MM/dd/yyyy hh:mm:ss tt";

        Log.Info("A message");
        // Output: [INFO][MM/dd/yyyy hh:mm:ss tt]: A message
    }
}

You can find more information about the date format here:

Last updated