Try
var transferEvents = contractInstance.Transfer({}, {fromBlock:0, toBlock:'latest'});
Source: How do I retrieve the Voted events from The DAO
Answer to question in the comment
Q the return seems a long string contain all logs. How can i split them one by one?
(from the same link above) I firstly use JSON.stringify(...)
to view the data:
> var theDAOVotedEvent = theDAO.Voted({}, {fromBlock: 1614771, toBlock: 'latest'});
undefined
> theDAOVotedEvent.watch(function(error, result){
console.log(JSON.stringify(result));
});
...
{"address":"0xbb9bc244d798123fde783fcc1c72d3bb8c189413","args":{"position":true,"proposalID":"15","voter":"0xebbf5d7d649aedde2c27a8b850a2a3862595eb53"},"blockHash":"0x3d0e8b47fbb03727c72585fbe2fd5f25c69c03f2b832753567c2309f1ecb3b2a","blockNumber":1614808,"event":"Voted","logIndex":0,"transactionHash":"0x0060654808a2dee9710fa01e26adb46e77df03c17e453e8fddc8749269ffad92","transactionIndex":1}
{"address":"0xbb9bc244d798123fde783fcc1c72d3bb8c189413","args":{"position":false,"proposalID":"11","voter":"0xebbf5d7d649aedde2c27a8b850a2a3862595eb53"},"blockHash":"0x607d940ebbbb17e6d5c3c8a871cd4783b271ddf71f4aeb83dbcdcaf8ce2154d9","blockNumber":1614812,"event":"Voted","logIndex":1,"transactionHash":"0x6b5cab6f7987d7283fdde051c76ace98c9f080bda6dbdf720689fc0c3958005b","transactionIndex":6}
{"address":"0xbb9bc244d798123fde783fcc1c72d3bb8c189413","args":{"position":false,"proposalID":"11","voter":"0xebbf5d7d649aedde2c27a8b850a2a3862595eb53"},"blockHash":"0x69be968ce90c7e910c149cc80ab1e5f2ae6bdb45f142ee0e6fa181be9d1e106e","blockNumber":1614812,"event":"Voted","logIndex":0,"transactionHash":"0x6b5cab6f7987d7283fdde051c76ace98c9f080bda6dbdf720689fc0c3958005b","transactionIndex":2}
...
Once you can see the data, you can reference each field, for example:
result.address
result.args
...