How to create log information

I am receiving the message from the mqtt sensor, i need to know how to store the events received from the sensor in some text or in any other file format

Depends on why you want to do this and in what format.

If you just want to see that the Item is being update and what it is being updated to, it is already written out in events.log.

If you want to see it in openhab.log you can create a rule and use the logInfo action to log it to a file.

If you want these updates to go to a separate file you can use the Logging Persistence binding.

i want to keep record of my sensor status w.r.t time and date .

Then either save the values to an external database like MySQL or use the logging persistence binding.