Ts3 Php Framework Get Log ALL

With php framework I am pulling 100 logs with $ ts3 Virtual Server-> logView (100) function but $ ts3_VirtualServer-> logView (101) or $ ts3_VirtualServer-> logView (99999)
I get an error when I do.
How can I get all my log records?

Error 1541: invalid parameter size

This post was flagged by the community and is temporarily hidden.

How about to stop opening new threads because nobody answers just in time?
Googling the documentation took a few seconds only…

Method and parameters

logView($lines  =  30,
    $begin_pos  =  null,
    $reverse  =  null,
    $instance  =  TRUE

Displays a specified number of entries (1-100) from the servers log.

If you want to load more log lines define the parameter $begin_pos as integer.
After loading the first 100 lines the value to begin with would be 101 and so on.

If you’re not capable of reading or understanding the documentation don’t spam the forum just to get an answer faster. Wait patiently like anybody else!


not working :confused:

I did not open a forum on the same topic twice. The first is how to pull logs and the second is how to pull all logs. Your management is useless man


Alright I’ll just ignore your frustration only because you don’t seem to understand the documentation.

The parameter $begin_pos as mentioned above doesn’t change the limit of the lines, it’s still 100.
$begin_pos just defines how many lines are skipped.

As I already said you’re going to read the first 100 lines and the next 100 lines after and so on.
(you don’t need to define the other parameters if you don’t set a value different than the default one)

Just an easy example:

print_r( $instance->logView( 100 ) );        // line   1 - 100
print_r( $instance->logView( 100, 100 ) );   // line 101 - 200
print_r( $instance->logView( 100, 200 ) );   // line 201 - 300

That manual build doesn’t make sense of course if you wan’t to read more lines.
If so do the following steps:

  • define an array
  • create a loop
  • call the logView() method
  • increase the second parameter by 100 each iteration
  • break; the loop if the result (array) has a size less than 100 - if not push the array into your created array (outsite the loop)
  • use your at the beginning defined array which should contain all arrays so with it all lines

It’s not that complicated but requires a some knowledge how to work with PHP of course.

(edit) Additional note:

Checking if the result (array) of logView() inside your loop has a size less than 100 to stop the loop will work only if the framework still doesn’t return the last 100 lines even if the value to skip is higher than the actual line count of the log file is. I don’t work with the framework thus I guess you will have to find out yourself.

1 Like

First of all, thank you for your time and reply. I’ll create an array and increase it to +100, but I don’t know how far

I don’t think we are here to code your app or whatever.
We can help with something though, but if you don’t have enough coding knowledge, you better start there first.

I think @FakE has explained it pretty much already.
Loop (Increase the $begin_pos) until the result is less than 100…

Watch your tone and learn some PHP basics…

As I explained in the other thread, the value for begin_pos must be the last_pos value from the previous result… it’s the cursor position inside of the log file. Check the first item in the array returned by the function.

Also, as stated in the documentation, the max number of lines to retrieve in a single command is 100.


First of all, my style is poorly understood for you, sorry.

$logs = $ts3_VirtualServer->logView(100,200,1);

echo "<pre>";
echo "</pre>";

normally the above code should show lines 201 - 300 but it doesn’t work.

Unfortunately, this is NOT how it works and the TeamSpeak Server documentation is wrong in this case. As I stated before, the begin_pos parameter of the logview command is NOT used to specify a number of lines to skip… instead, it specifies the position of the read cursor in the log file. You can see this in the output you posted as the date in the beginning of the second element in your output is incomplete.

Don’t ask me why… but that’s how it’s been implemented in the TeamSpeak Server.

So in fact, the function call you made does this:

Hey dude, give me 100 lines from the log starting after 200 bytes (characters)… pretty please.

To get the full log, what you actually need to do is this:

$log = array();
$pos = 0;

    // grab 100 lines starting at $pos bytes
    $lines = $ts3_virtualServer->logView(100, $pos);

    // remember cursor position of last line ending we got
    $pos = $lines[0]["last_pos"];

    // parse and save lines
    foreach($lines as $line) {
      $log[] = TeamSpeak3_Helper_Convert::logEntry($line["l"]);
  // do the above until no more content is available
  while($pos && $pos <= $lines[0]["file_size"]);
catch(TeamSpeak3_Exception $e)
  // print error message in case something goes wrong
  die("ERROR" . $e->getCode() . ": " . $e->getMessage());

// dump what we got

However, I would not recommend to always grab the full log as it can get very large so what you should to is implement some kind of pagination to allow the user to navigate to newer/older log entries instead. Remember… you’re working on a file… not a database.

1 Like

That was the answer I was looking for. Thank you <3

twitch instagram twitter facebook