Enable sip debugging with:

For Asterisk 1.6:

asterisk -rx "sip set debug on"

For Asterisk 1.4:

asterisk -rx "sip debug"

To create a log file :

asterisk -rvvvvvvvvvvvvvvvvvvvvvvvvvvvvv >/path/to /file.txt