Jump to content
Sign in to follow this  
SINE

Log files since last update

Recommended Posts

Hello Dear Ladies and Gentlemen from BIStudios and the Forum,

I'd like to setup my server so it doesn't create .log files per each session, but only one as it used to be before the last update.

The log files I mean are those configured by:

logFile            	= "A3Master.log";

For us it doesn't write into this file any longer but creates infinite others instead (a new one for each session, sometimes using an old one).

Is that possible somehow?

But if not, could someone please explain the filenames, because to us they don't make any sense?

An example for the filenames:

A3Master_1180.log

A3Master_956.log

Share this post


Link to post
Share on other sites

I think it needs to be in youe start up pram:

#!/bin/bash

# Wrapper file to start the A3 server

# Network settings used in -cfg param

networkConfig="network.cfg"

# Server configuration settings used in -config param

serverConfig="server.cfg"

# Server profile and difficulty settings used in -name param

profileName="server"

# Server-side mods

mods="@cba_a3"

# Stop old server

kill -9 `cat .pid`

# Start server

nohup ./arma3server -cfg="/$networkConfig" -config="$serverConfig" -name="$profileName" -mod="$mods" -port=2302 -noSound > arma3.log 2>&1&

echo $! > .pid

Share this post


Link to post
Share on other sites

The config works fine, it just changed in the last update and doesn't create only one log file but one for each session.

Edited by SINE

Share this post


Link to post
Share on other sites

best bet is to post more info, i have errors in my set up diffrent from yours ( my server is always yellow) .

it seems theres realy not enuf infomation on linux or the info isnt for noobs (me being a noob).

i realy wish somone would just flat out post there linux files that work properly.

Share this post


Link to post
Share on other sites
best bet is to post more info, i have errors in my set up diffrent from yours ( my server is always yellow) .

it seems theres realy not enuf infomation on linux or the info isnt for noobs (me being a noob).

i realy wish somone would just flat out post there linux files that work properly.

Yea I was wondering on how to get mine to green, it works nice so far except for not making any RPT logs in .local/share/Arma 3 or anywhere on the entire system :s

Share this post


Link to post
Share on other sites

But if not, could someone please explain the filenames, because to us they don't make any sense?

An example for the filenames:

the number you see created in your logfile is the pid the server had/has when it started.

Share this post


Link to post
Share on other sites

Oh, I see. Though the name doesn't help at all in that case.

Does anyone have a solution?

Share this post


Link to post
Share on other sites

Well. to get only 1 logfile i guess you need to create some sort of script. that checks the date on the file, and run this script before or after the server is shutdown.

because, the logfile is empty at startup. and it only creates content in the file after you do a #shutdown.

(atleast with me) which i find verry strange.

why does the server not append text to the logfile as stuff are outputed to the console.

if you have a server running for a verry long time with many players and sessions means the server mem usage will be rather high.

it will grow and grow until the server is #shutdown. it then it writes all the stuff to the logfile. "stupid method" if you ask me.

i also see other issue. such as. if you restart your server lots of times. you will get lots of files with pids in them.

what will happen when you have so many file that when your server starts up and it gets the same pid as one of the exsiting files!.

will it append to it or overwrite it?

using date as the rpt file would be much smarter if you ask me.

never the less. i dont know if its possible to do what you want by using bat or cmd script. but using other languages such as python will solve your problem.

this is something i cooked up in 10 min. i dont know if you like to use it. altho it should be written a bit better. more error handeling etc.

but thats left to DIY :p

import os, sys, time, codecs
# #################################
# Settings
# #################################

# Define the path to the logfiles.
PATH = "C:\\Program Files (x86)\\Steam\\SteamApps\\common\\Arma 3\\servercfg\\" # Note the double \\ in the path and at the end..

# Name of logfile, this is whats in your server.cfg file. this will be our master file.
LOGFILE = "server_console.log"

# #################################
# Some Code
# #################################

# split the string up and separate the filename and extension. "will error on missing or to many dots(.)"
FILE, EXT  = LOGFILE.split(".") 

# Get all relevant files from our path. exclude 0 sized and the master log itself.
FILES = [fn for fn in os.listdir(PATH) if fn.startswith(FILE) and fn.endswith(EXT) and os.path.isfile(PATH+fn) and os.path.getsize(PATH+fn) > 0 and fn != LOGFILE]

# Sort the files by time.
FILES.sort(key=lambda x: os.path.getmtime(PATH+x))

# If we have one or more log file, continue.
if len(FILES) >= 1:

   # create and open a file object to be writen to. "master file"
   mf = codecs.open(PATH+LOGFILE, 'a', encoding="utf-8-sig",errors="ignore")

   # loop over all the collected files in your path
   for e in FILES:
       # open the session log
       slog = codecs.open(PATH+e,'r', "utf-8-sig", errors="ignore")
       for line in slog:
           # write lines to master log file
           mf.write(line)
       # close current session log
       slog.close()

       # give the interpreter some time to close the fileobj properly.
       time.sleep(0.1)

       # To avoid adding this content more than once to the main file if we use writetype 'a'. we rename, move or delete the session files
       # Examples, select your method by uncomment the os.rename(..

       ##################################################################        
       # METHOD 1
       # just rename the sessionlogs to filename.log-OLD
       os.rename(PATH+e, PATH+e+"-OLD")

       ##################################################################
       # METHOD 2
       # Delete the session logs.
       #os.remove(PATH+e)

   # Close the main log file
   mf.close()
else:
   print "No files to merge with the master log file",LOGFILE

you will need python to run this. the script is written for python 2.6

and if your using a bat script to start your server you want to have this running before you start the server up.

you could add something like this to your bat file

set python=c:\python26\python.exe
%python% logmerger.py
:: more armastuff

Or if your using other tools to start up the server. such as firedaemon. make sure this is run as preinit (before the server is started)

hope this is of any help to you.

Share this post


Link to post
Share on other sites

the _number is PID (process ID) number ... it's to ensure log files don't overlap from different processes and sessions ...

Share this post


Link to post
Share on other sites
if you restart your server lots of times. you will get lots of files with pids in them.

what will happen when you have so many file that when your server starts up and it gets the same pid as one of the exsiting files!.

will it append to it or overwrite it?

using date as the rpt file would be much smarter if you ask me.

[...]

Yes, I absolutely agree with this point.
[...]

this is something i cooked up in 10 min. i dont know if you like to use it. altho it should be written a bit better. more error handeling etc.

but thats left to DIY :p

[...]

Thank you very much for your time and this excellent piece of code, I didn't test it yet but I think this will be a good workaround until the devs of Bohemia Interactive will decide something more comfortable than at the moment.

---------------------------

Hello Dwarden.

I understand but they do overlap when you restart the server atleast 4 times a day for atleast 1 month, there is overlapping, the text files add upon eachother and it's complete chaos. We have many files which are not from one, but two or three different sessions.

Please, at least give an option to write to only 1 file as it used to be (configured through the cfg file).

We never had any hint of a problem with the old system.

PS: Personally, I think it would be way better to use PID+time+date stamps as the filenames for the multiple logfiles system, as there would never be any kind of overlapping, just as nuxil suggested above.

Edited by SINE

Share this post


Link to post
Share on other sites

I will see what I can do, it's still better than it was ... yet there is more what can be done on the less chaotic logging :) especially with lot of servers / single box

Share this post


Link to post
Share on other sites

Idk if i would call it better. atm its a big mess if you ask me.

Using date instead of the pid would solve alot of problems. i have no issues that it creates one new file for each time the server is booted up.

I find this pid naming idiotic and it seems to be rushed into service without any big thoughts.

I dont know why Bis desided to use the pid as part of the log file name, since the chance of getting the same pid on the server as one of the current file have over time is rather high.

One other thing that also annoys me is the way text are written to the logfile.

As it is now. it write ALL the "server concole text" to the session log file only when you do a clean shutdown of the server.

so if you have a server running for 3++ hours with lots of people connecting,disconnecting, chatting etc and the server does crash.

you get a logfile that is 0 in size. in other words. it doesnt write anything to the log file.

Instead of writing ALL the "server console text" to the logfile at shutdown. text to the file should be appended to the logfile as text are outputed in the console.

and ofc class Session should be written between missions.

or if thats to much i/o, it can be done in blocks. write to the file when you get have 50 line or so, or done by time interval.

Share this post


Link to post
Share on other sites

the reason to use PID is simple, try run 13 servers on same box or restart server often, also on Windows you barely run into chance of PID overlap even after week of daily restarts

Share this post


Link to post
Share on other sites
the reason to use PID is simple, try run 13 servers on same box or restart server often, also on Windows you barely run into chance of PID overlap even after week of daily restarts

Well Dwarden. using date would still be better.

Let me ask you this, are you running 13 server on the same box using 13 identical server configs ?

No youre not. so for each server you just do something like.

In config for server 1.

logFile = "Server1.log"

In config for server 2.

logFile = "Server2.log"

And so on.

Nor do i belive you have all the server config files located in the same directory and want to save all the logfiles to the same dir. If you do so, the chance of overlapping is even higher if you use same identical names, in fact its 13 times higher chance of overlapping in this case...

Using date within the filename, there is 0 chance of overlapping. Unless you turn back your system clock and magicaly manage to start the server at the same precise time.

Even if you make a script to move the server logs out to a "logdir" for backup ("without renaming them"). you can end up with duplicated files that looks like copies.

in rare cases you end up with something like this if you try to move the files to a logdir..

Server1_123.log

Server1_123 (2).log

Server1_123 (3).log

this would never happen with timestamps in the filename

Edited by nuxil

Share this post


Link to post
Share on other sites

ye I would prefer yourdefinedname_date_pid ... (after 1.20 I will try to get it done)

Share this post


Link to post
Share on other sites

Thanks guys, I'm really looking forward for this change to the better.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×