Skip to content

Using the built in server logger

FCheat edited this page Jun 29, 2018 · 1 revision

How to use the Unturned-Unity built-in pre-packed logging system.

One may be asking, how do I log without adding my own logger?? Doesn't Unturned have one?

Well, yes it does! Others would tell you to make your own because they simply don't know how to reach the logger.

Let's hop right on in 👍


First, looking around there's a command, CommandLog in SDG.Unturned, which in reality calls to the CommandWindow, aka SDG.Unturned.CommandWindow + .Log/.LogError

And, SDG.Unturned.CommandWindow.Log(Object, ConsoleColor) in reality just adds to the games console window, then calls back to UnityEngine.Debug.Log/LogError

  • Ensure you reference UnityEngine.dll from the managed folder in your game install folder!

Then, this takes it a step further and calls back to the type logger in debug. And in this, there's multiple types.

Log, LogError, LogException, LogFormat, LogWarning, and the typical Log accepts multiple types itself if you want to really do it all how you want.

For example:

UnityEngine.Debug.logger.Log(UnityEngine.LogType.Log, "input");

Can be transferred to:

UnityEngine.LogType.Assert
		   ...Error
		   ...Exception
		   ...Warning

and so on.

All logs will be saved to the UnturnedInstallFolder/Logs/Server_servername.log

Reading input and adding game commands is extremely easy to add if you peek around the Console class, good luck.

POC

Clone this wiki locally