Are you running plain Asterisk? If so you can modify your dial plan to start 'monitoring' the channel, which will record the call.
The monitor command's documentation: http://www.voip-info.org/wiki/view/Asterisk+cmd+monitor
Just for the sake of completion, here's the documentation:
[root@localhost ~]# asterisk -rx 'core show application monitor'
-= Info about application 'Monitor' =-
[Synopsis]
Monitor a channel
[Description]
Monitor([file_format[:urlbase],[fname_base],[options]]):
Used to start monitoring a channel. The channel's input and output
voice packets are logged to files until the channel hangs up or
monitoring is stopped by the StopMonitor application.
file_format optional, if not set, defaults to "wav"
fname_base if set, changes the filename used to the one specified.
options:
m - when the recording ends mix the two leg files into one and
delete the two leg files. If the variable MONITOR_EXEC is set, the
application referenced in it will be executed instead of
soxmix and the raw leg files will NOT be deleted automatically.
soxmix or MONITOR_EXEC is handed 3 arguments, the two leg files
and a target mixed file name which is the same as the leg file names
only without the in/out designator.
If MONITOR_EXEC_ARGS is set, the contents will be passed on as
additional arguments to MONITOR_EXEC
Both MONITOR_EXEC and the Mix flag can be set from the
administrator interface
b - Don't begin recording unless a call is bridged to another channel
i - Skip recording of input stream (disables m option)
o - Skip recording of output stream (disables m option)
By default, files are stored to /var/spool/asterisk/monitor/.
Returns -1 if monitor files can't be opened or if the channel is already
monitored, otherwise 0.
And here's a sample way you can use it:
; This fake context records all outgoing calls to /var/spool/asterisk/monitor in wav format.
[fake-outgoing-context]
exten => s,1,Answer()
exten => s,n,Monitor(wav,,b)
exten => s,n,Dial(DAHDI/g0/${EXTEN})
exten => s,n,Hangup()
Obviously you'd have to make changes to my code, but hopefully that gives you a good idea.