This technique has been proven again and again and again. Here it is, explained by its originator, University of Pennsylvania professor Martin Seligman.

Via Flourish: A Visionary New Understanding of Happiness and Well-being:

Every night for the next week, set aside ten minutes before you go to sleep. Write down three things that went well today and why they went well. You may use a journal or your computer to write about the events, but it is important that you have a physical record of what you wrote. The three things need not be earthshaking in importance (“ My husband picked up my favorite ice cream for dessert on the way home from work today”), but they can be important (“ My sister just gave birth to a healthy baby boy”).

Next to each positive event, answer the question “Why did this happen?” For example, if you wrote that your husband picked up ice cream, write “because my husband is really thoughtful sometimes” or “because I remembered to call him from work and remind him to stop by the grocery store.” Or if you wrote, “My sister just gave birth to a healthy baby boy,” you might pick as the cause “God was looking out for her” or “She did everything right during her pregnancy.”

Writing about why the positive events in your life happened may seem awkward at first, but please stick with it for one week. It will get easier. The odds are that you will be less depressed, happier, and addicted to this exercise six months from now.