See the video and you will find how to generate the logs using log4j. Here I am using it to Appium. Check the 4th video of the series.
How to get the packageName and packageActivityId to automate Android app in appium
Open command prompt and type adb devices
If it shows devices connect then type
If all those well then type shell command
dumpsys window windows | grep -E ‘mCurrentFocus|mFocusdApp’
You will be able to see the packageName and packageActivityId