Logout logged in user with testng annotation

Can someone tell me how I can handle situation with test ng

I want to logout app before I start test execution if the user is already logged in with app so that can start execution from step 1 which is login user

Can I include any code inside listeners onTestStart() function?

with testNG you can use

@BeforeMethod
public void beforeMethod() {
 // here your code to reset or logout
}

Thank you for info. It works fine now