JustaPenguin / assetto-server-manager

A web interface to manage an Assetto Corsa Server.
https://github.com/JustaPenguin/assetto-server-manager/releases
MIT License
279 stars 70 forks source link

Find a solution for acServer not producing server log files #394

Closed WraithStar closed 5 years ago

WraithStar commented 5 years ago

Kunos had the genius idea to have Assetto Corsa not producing log files by itself, they went for the lazy way and bundled this batch file to launch the server executable with. This is the only way we can get server log files (on Windows).

@echo off
TITLE AC Server
echo Starting AC Server...
SETLOCAL EnableDelayedExpansion
 for /f "skip=1 tokens=1-6 delims= " %%a in ('wmic path Win32_LocalTime Get Day^,Hour^,Minute^,Month^,Second^,Year /format:table') do (
        IF NOT "%%~f"=="" (
            set /a _d=10000 * %%f + 100 * %%d + %%a
            set /a _t=10000 * %%b + 100 * %%c + %%e
        )
    )

echo Output is logs/session/output%_d%_%_t%.log

acserver.exe > logs/session/output%_d%_%_t%.log 2> logs/error/error%_d%_%_t%.log

The problem is pretty evident: with acServer not producing log files by itself, we have to tell Server Manager to write these files in some way, if we want them

Hecrer commented 5 years ago

Options are:

WraithStar commented 5 years ago

Workaround (thanks @cj123 for the idea) - tested and working on both Windows and Linux Basically, the idea is to redirect AC's standard output directly to a logfile....as Kunos (lazily) intended

NOTE: this will stop showing the log in the manager's Server Log page, but at least we will have the outputs printed on logfiles.

#!/bin/bash
LOGFILE=`date "+%Y-%m-%d_%H.%M.%S.log"`
./acserver >$LOGFILE
@echo off
TITLE AC Server
echo Starting AC Server...
SETLOCAL EnableDelayedExpansion
 for /f "skip=1 tokens=1-6 delims= " %%a in ('wmic path Win32_LocalTime Get Day^,Hour^,Minute^,Month^,Second^,Year /format:table') do (
        IF NOT "%%~f"=="" (
            set /a _d=10000 * %%f + 100 * %%d + %%a
            set /a _t=10000 * %%b + 100 * %%c + %%e
        )
    )

echo Output is logs/%_d%_%_t%_server01.log

acServer.exe > logs/%_d%_%_t%_session_server01.log 2> logs/%_d%_%_t%_error_server01.log
cj123 commented 5 years ago

Closing this ticket via the new wiki entry on ACServer Logging to File. Thanks to @WraithStar for the testing here :)