How to debug FOP2
FOP2 is a two component software. There is a server daemon that runs on your Linux server, and a client application that runs on your web browser. Troubleshooting might be difficult because of this, because a problem might happen on either side (client or server), and logs are separate from one another.
Server Side Debug
In order to capture debug output on the server side you must pass some command line options to the fop2_server binary:
- -X Log Level
- -l Log Directory
Log level is a bitwise operator, that means that depending on the bit some particular messages are going to be logged. The bit table is this:
|1||AMI Events received|
|2||AMI Commands sent|
|4||FOP2 Client events received|
|8||FOP2 Client command sent|
For enabling full debug, the level to use is 511 ( 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1)
If you want to enable only AMI Events/Commands, set debug level to 3 ( 2 + 1 )
So, if you want to start FOP2 with full level debug, and storing the debug log (named fop2_debug.log) into the /var/log directory, you should pass the following parameters to the fop2_server binary:
-X 511 -l /var/log
In order to pass those parameters to the service init script you must edit the settings file and add those options. On a Centos/RedHat based system, the file to edit is /etc/sysconfig/fop2 , while on Debian based distributions, the file is named /etc/default/fop2. So go ahead and edit the file, leave any options you might have already set there, like -d, and just append the new options, so it will look similar to this:
OPTIONS="-d -X 511 -l /var/log"
It is very important to NOT remove any other command line options you might have specified there, otherwise you will most probably break your init script.
Once the file is modified, restart FOP2.
On Centos/RedHat run
service fop2 restart
On Debian/Ubuntu run
Once the service is restarted, you will have a /var/log/fop2_debug.log file with information that will help troubleshooting / debugging issues.
By default the fop2_debug.log does not have a timestamp for events. But you can use a dialplan trick/hack in order to get timestamps out of it, you can run this to parse the log and save another log file with timestamps in it:
tail -f file |xargs -IX printf "$(date -u)\t%s\n" X > /var/log/fop2_debug_timestamps.log &
Be careful as the log file will grow really big if you enable full debug, and if you do not take care of log rotations it might fill your hard disk if you forgot to turn debug off.
To remove debug, just edit the same file you changed before and remove the -X and -l parameters from it and restart FOP2 again.
Client Side Debug
If you use Google Chrome, the shortcuts to open the console are:
On Windows: Ctrl + Shift + J
On Mac: Cmd + Option + J