Great to see it works! - you need to reformat the card as advised - it just makes debugging easier (based on my past experiences )
So now you know the connections and card work - you can try the logger code, knowing thats is only related to the library being used (or perhaps how you are using it in your code)
Thanks @jphil for the suggestions. @shanevanj formatted the sdcard using the formatter. What if the issue is related to the shield. Is there a chance the writing speed is not compatible for it? I am using SanDisk class 4 sdcard. Thanks for all the inputs.
I'm not sure of that since F_CPU (used to calculate half of that) is not declared IIRC.
However, you can also use a numeric value for the clock speed (e.g. 8000000 for 8MHz).