How to write specific events to a custom file?

I am a beginner in openHAB and I was wondering if it is possible to write specific events into a custom file which I can use later.
I couldn’t find any relevant documents on this, so any help would be appreciated.

This should be a good starting point:
http://docs.openhab.org/administration/logging.html

See the part “Logging into Separate File”

HTH,
-OLI

I have already checked this, and made changes to the org.ops4j.pax.logging.cfg file as mentioned in this doc.
I want to log specific events into the demo file, but unable to progress.
Sorry if the question is stupid. But am a complete newbie in this.

Could you be more specific on the “specific events”?
also posting the changes you’ve made to the cfg file would be usefull…

I am using a homematic system with openHAB running on a Pi.
I want to monitor the state changes for a homematic wireless actuator and log them into a separate file, part of my Master’s project, to note down the user activities.
I am still unsure what should be the correct approach, since I plan to develop a system which can automatically send timed commands to the devices to emulate user activity pattern(like if the user daily turns the device on at a particular time, the automated system can do the same in the user’s absence).
Could you guide me with the correct approach to do this?

I am still reading through the documentations on logging, yet to fully understand it.

I don’t think you should do this via the logging.

I think you should look at using persistence to save event changes. Then you can read those changes from the database, and you will have a nice query language to get the data you are interested in.

I have seen others talk about creating such a system which can repeat changes to make it appear one is home, I think even here within Openhab. Do a bit of googling.

So, after some struggling I have managed to log the events into a specific file using the following rule:

rule "User Pattern ON"
     when
     Item MySwitch changed from OFF to ON
     then
     var SimpleDateFormat df = new SimpleDateFormat( "YYYY-MM-dd HH:mm:ss" )
     var String Timestamp = df.format( new Date() )
     logInfo("Demo",Timestamp + " TimeStamp for user pattern on")
     end
     
     
    rule "User Pattern OFF"
     when
     Item MySwitch changed from ON to OFF
     then
     var SimpleDateFormat df = new SimpleDateFormat( "YYYY-MM-dd HH:mm:ss" )
     var String Timestamp = df.format( new Date() )
     logInfo("Demo",Timestamp + " TimeStamp for user pattern off")
     end     

Now I want OpenHAB to read the Demo file and take the time values so that I can create a rule to replicate the user patterns. But I guess the standard JAVA syntax like istream won’t work with this, and am unable to find any workaround.