Log Files

Discuss the new AI features ("NoAI") introduced into OpenTTD 0.7, allowing you to implement custom AIs, and the new Game Scripts available in OpenTTD 1.2 and higher.

Moderator: OpenTTD Developers

Post Reply
Carolusclen
Engineer
Engineer
Posts: 8
Joined: 31 Dec 2016 10:59

Log Files

Post by Carolusclen »

Hey everyone

I am trying to find out how to dump the console of a Dedicated server to a log file.

The closest thing i could find all day was by using a script like so

File name: On_dedicated.scr
Content;
echo "Starting server"
script openttd.log

The issue is that the "script openttd.log" is not verbose

my questions is, is there ANY WAY to have the console window write to a log file in verbose mode
I do know the Linux has a command line that writes it to file because of the lack of a window. Wish there was a PC version to that.

Thanks :)
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Log Files

Post by planetmaker »

<smartass>I run linux on my PC. So there definitely is.</smartass>

There's some way to convert OpenTTD to a console application on windows, too - but I don't recall how. But it's for sure somewhere here in this forum or in our wiki. Try searching for something like "OpenTTD console windows" or such on the search bars of these pages.
Carolusclen
Engineer
Engineer
Posts: 8
Joined: 31 Dec 2016 10:59

Re: Log Files

Post by Carolusclen »

planetmaker wrote:<smartass>I run linux on my PC. So there definitely is.</smartass>

There's some way to convert OpenTTD to a console application on windows, too - but I don't recall how. But it's for sure somewhere here in this forum or in our wiki. Try searching for something like "OpenTTD console windows" or such on the search bars of these pages.

haha fair enough. Ill have a look at consoles then. I do know running openttd with the -D commandline runs is as a console dedicated server. I still cant find how to dump that console to a log file D:
Carolusclen
Engineer
Engineer
Posts: 8
Joined: 31 Dec 2016 10:59

Re: Log Files

Post by Carolusclen »

Ok, so I found a way around it for now. For anyone else looking into this, do the following. This goes based on a basic knowledge of powershell scripts

Open a text file and type in the following

Code: Select all

Start-Process -FilePath ".\openttd.exe" -Argumentlist "-D -d 4" -RedirectStandardError "logfile.log"
then save it as Server.ps1

Basically what this does is
1) This starts a new windows process of openttd.

Code: Select all

Start-Process -FilePath ".\openttd.exe"
2) This assigns the command line options to the process. In this case its -D for dedicated server and -d 4 for level 4 debugging

Code: Select all

-Argumentlist "-D -d 4"
3) This redirects all the info from the console window to the text file of your choosing.

Code: Select all

-RedirectStandardError "logfile.log"
I have uploaded a script for peoples convenience.
Please note for the new people in powershell scripting, your computer may need to have the powershell "run custom scripts" enabled. here is a link to learn how https://technet.microsoft.com/en-us/lib ... 76961.aspx

https://www.dropbox.com/s/rfuoincj3uk1h ... r.ps1?dl=1

If you want to see the content of the file, just open in notepad
HGus
Engineer
Engineer
Posts: 121
Joined: 12 May 2013 22:28
Location: Argentina

Re: Log Files

Post by HGus »

If you try:

Code: Select all

.\openttd.exe -D -d 4 >logfile.log
... in a standard cmd script?
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 6 guests