It's a method you can throw into a custom class, it's not a complete script.
Create a new command class, register the command using Commands.Register(...) (there are a lot of examples), and have it execute the LogActivePlayers method.
You can edit it as such if it makes more sense;
public...