seriously sir your tutorial got me out from 24 hrs wasted on checking from every where but your simple method solve my trouble of log 4j2 just 20 minutes thank you so much
@RaghavPal2 жыл бұрын
So happy to know Onkar
@nadiyagone84315 жыл бұрын
Am tied up watching all log4j videos and didn't any solution for making log 4j in maven project. But from this video I was successfully created logs without any errors. Thank you so much for making this video sir....
@RaghavPal5 жыл бұрын
Glad to know it helped Nadiya
@NPRBEST5 жыл бұрын
Best tutorial for log4j on internet. Explained with great details...no doubts...
@RaghavPal5 жыл бұрын
So glad to know this Nayan
@ashwinireddy6832 Жыл бұрын
As usual ver y well explained and never disappointed, I have been following your tutorials for my new job trials.
@RaghavPal Жыл бұрын
Great to hear Ashwini. Best wishes
@jaquelinecuatepitzibastida41632 жыл бұрын
THE BEST VIDEO I HAVE SEEN ON THE SUBJECT!! Thank you very much, it has helped me a lot. The entire playlist is a gem.
@RaghavPal2 жыл бұрын
Thanks Jaqueline, humbled
@Nstyleonlineuk2 жыл бұрын
just perfect ! clean and tidy explanation !thank you very much!
@RaghavPal2 жыл бұрын
Most welcome
@virendrasinghbais90285 жыл бұрын
You never disappoint. Thanks and keep posting more. Try covering end to end development videos
@RaghavPal5 жыл бұрын
Sure Virendra, Thanks for watching
@Mostafizur_rahman1884 жыл бұрын
This is exactly what I was looking for. This playlist is very helpful, helped me to PRACTICE before going out for interview. But in my opinion, this is not a beginner course......
@RaghavPal4 жыл бұрын
Glad to know it helped Mostafizur. I will plan for more basic details
@Shivakumar-nl2li4 жыл бұрын
@@RaghavPal Bro do file handling reading and writing ops as there are new changes in Apche POi
@shehlaabdullah5374 Жыл бұрын
Thank you so much ..we learn alot of thing about automation .. really appreciate sir ...
@shehlaabdullah5374 Жыл бұрын
I m very very thankful to you ..automation ko jitna mn mushkil smjha tha ..sir you make it easy for me..... You explain each everything..in detail
@RaghavPal Жыл бұрын
So happy to know it helped
@sridharmamidipaka62522 жыл бұрын
Very good bro Do more and more and boostup us
@RaghavPal2 жыл бұрын
Sure Sridhar
@ankurmishra85084 жыл бұрын
Simply .......as wonderful as always .....thanku sir
@RaghavPal4 жыл бұрын
Always welcome Ankur
@rhacker00073 жыл бұрын
Hi Raghav, thanks a lot !! The information you provided will enough to rock the technology.. Thanks once again 😃..
@RaghavPal3 жыл бұрын
Most welcome
@deviyadlapalli30113 жыл бұрын
Very neat and clear explanation thanks for your help..
@RaghavPal3 жыл бұрын
You are welcome Devi
@immuind20093 жыл бұрын
well explained Raghav
@RaghavPal3 жыл бұрын
Thanks Imtiaz
@brucemyklebust88864 жыл бұрын
thank you! this is exactly the video I was looking for
@RaghavPal4 жыл бұрын
You're welcome Bruce
@vigneshviky92482 жыл бұрын
Clearly explained thanks bro...........
@RaghavPal2 жыл бұрын
most welcome
@kamaljitxSingh3 жыл бұрын
Hi raghav, You have explained in very neat manner, especially at the end of the video. Thanks, this will be very useful for me in company.
@RaghavPal3 жыл бұрын
You are most welcome Kamaljit
@sumithak93455 жыл бұрын
Clear video on log4j👍🏻
@RaghavPal5 жыл бұрын
Happy to know it helped Sumitha
@philb44622 ай бұрын
This is a great "how to" video. What I am struggling to find is anything that tells me "when to". Can you give some real-world examples of what you should actually put in log messages of each level? Should we log every action, such as text entry and button-clicks? Should we put a log instruction in each method in our POM files? I'm looking for actual examples rather than technical instructions. Is there anywhere I can find "good practice" advice on deciding on logging messages?
@RaghavPal2 ай бұрын
Phil In a Selenium Java project using Log4J, it's essential to log messages appropriately based on their significance. Here are real-world examples for each log level: TRACE: Use this for very detailed messages that are useful for debugging. Example: logger.trace("Entering method loginUser (). User ID: {}", userId); DEBUG: Ideal for logging detailed information during development and testing. Example: logger.debug("Entered username: {}", username); INFO: Use this for general information about application flow. Example: logger.info("User {} logged in successfully.", username); WARN: Indicates potential issues that may need attention. Example: logger.warn("User {} attempted to access a restricted page.", username); ERROR: For logging error events that might still allow the application to continue running. Example: logger.error("Failed to find element by ID: {}", elementId); FATAL: For serious errors that might cause the application to terminate. Example: logger.fatal("System crash due to unhandled exception: {}", exception.getMessage()); Should You Log Every Action? Text Entry and Button Clicks: It is not necessary to log every single action, such as every text entry or button click, as this can lead to excessive log volume and make it difficult to find important information. Instead, focus on logging significant actions, like: User logins Form submissions Errors or exceptions Logging in Page Object Model (POM) Method Logging: It is advisable to log significant events within methods in your POM files, but avoid cluttering every method with log statements. Focus on: Entry and exit points of methods Key actions (e.g., navigating to a page, submitting a form) Errors or exceptions Good Practices for Logging Messages Clarity: Ensure log messages are clear and provide context. Consistency: Use a consistent format for log messages across your application. Avoid Sensitive Information: Do not log sensitive data like passwords or personal user information. Log Levels: Use the appropriate log level to reflect the severity of the message -
@philb44622 ай бұрын
@@RaghavPal Thank you so much. You're amazing! I'd like to suggest you do a video on this. It's incredibly hard to find this kind of information. I've been looking for months. It would be very valuable and unique. I can't be the only one looking for this guidance. All the information out there is technical. There is barely anything practical like your answer here.
@RaghavPal2 ай бұрын
Sure, will do
@sirisham49922 жыл бұрын
good explanation
@RaghavPal2 жыл бұрын
Thanks Sirisha
@atulthorat56702 жыл бұрын
Thank you So Much Raghav....
@RaghavPal2 жыл бұрын
Most welcome Atul
@poornimap34553 жыл бұрын
crystal clear super
@RaghavPal3 жыл бұрын
Thanks Poornima
@manikandan-zb8kp3 жыл бұрын
very helpful video , can you also explain how to add test case for same.
@RaghavPal3 жыл бұрын
I will plan on this Mani
@ahsan3223 жыл бұрын
Hi Raghav, First thanks for all efforts for us. I am facing a issue. As following this clip Log file is getting generate in logs folder but logs are not getting append inside the file. It show blank, where as logs are showing on console. Please guide on this. Thanks.
@RaghavPal3 жыл бұрын
will need to check the settings and configuration file
@lucylucy85174 жыл бұрын
It's a very detailed explanations thank you.
@RaghavPal4 жыл бұрын
You are welcome! Lucy
@radyshrek39543 жыл бұрын
Really great tutorial! Good job guy!
@RaghavPal3 жыл бұрын
Thanks
@mallikarjunaswamyb37655 жыл бұрын
Hi Raghav, I have done as you explained but in log4j2 properties, you mentioned the package name as demo.. If you want to use the same logger obj out of other java packages, it is not writing the logs in the file but in console it works. Can you help me out in this???
@RaghavPal5 жыл бұрын
Hi Mallikarjun, did you try to import the class wherever you want to use it
@Thuster5 жыл бұрын
@@RaghavPal which files are you asking to import here and where are they supposed to be imported?
@sonikaraina85534 жыл бұрын
to the point explanation ...thank you
@RaghavPal4 жыл бұрын
You're welcome Sonika
@EliasHossein7994 жыл бұрын
I will say just amazing explanation....
@RaghavPal4 жыл бұрын
Thanks Md Shah
@saurabhdichwalkar69694 жыл бұрын
Thanks manhhhh this video helped me to solve one silly doubt. Thanks much 😊
@RaghavPal4 жыл бұрын
Most welcome Saurabh
@MeenaK-i6w2 ай бұрын
Very nice explanation, but a beginner's question, what is log4j's use in selenium automation scripting? didnt understand that.could you please explain.
@RaghavPal2 ай бұрын
Meena Log4j is a Java-based logging utility that allows developers to log events in their application. Why is Log4j used in Selenium? Log4j is used in Selenium to: Debug issues that arise during test execution Report errors and exceptions that occur during test execution Monitor test execution and provide insights into test performance How is Log4j used in Selenium? Log4j is configured using a properties or XML file, and is used to log events and errors during test execution. It can be used in conjunction with a testing framework like TestNG or JUnit.
@sathyasachin16965 жыл бұрын
Is it possible to add multiple value for key?, I want to display log for multiple packages. How can I achieve this? I have created framework for my project which had multiple packages.
@RaghavPal5 жыл бұрын
Hi Sathya, I have not tried this but you can create multiple log files. This may helpful - stackoverflow.com/questions/27941144/how-to-create-multiple-log-files-using-log4j examples.javacodegeeks.com/enterprise-java/log4j/log4j-writing-different-log-files-example/
@Mithunkumar-kq3vt4 жыл бұрын
@@RaghavPal These example explains log4j. Can u help me to find a solution for multiple packages? As Sathya said, Even i Want to integrate into the framework .
@akshay97513 жыл бұрын
This worked for me for adding multiple packages and particular classes for logs: #loggers label loggers= A,B #loggerA configuration #Package/Class: packages or classes path logger.A.name= com.packageA logger.A.name= com.packageB.classname1 #Level: debug logger.A.level = fatal #Using: file logger.A.appenderRefs = file #Settings reference: LOGFILE logger.A.appenderRef.file.ref = LOGFILE #False: only consider logger logger.A.additivity = true #loggerB configuration #Package/Class: packages or classes path logger.B.name= com.packageB.classname2 #Level: debug logger.B.level = trace #Using: file logger.B.appenderRefs = file #Settings reference: LOGFILE logger.B.appenderRef.file.ref = LOGFILE #False: only consider logger logger.B.additivity = true and below this you can add rootlogger
@Yaddalapudi5 жыл бұрын
9:08 i am not getting any error there what ever i am printing that prints in console ,what the problem
@RaghavPal5 жыл бұрын
Hi Krishna, I will need the error details/logs to troubleshoot
@Yaddalapudi5 жыл бұрын
@@RaghavPal your getting in this video right,but I not getting any error,all ok
@RaghavPal5 жыл бұрын
Okay, great.
@mohammedsaif79164 жыл бұрын
Could you please check the version of log4j-api and log4j-core dependencies I also got the same doubt in the initial stage of practical session. After changing the version for both dependencies to 2.5, it worked for me Try to change the version and see. It might work
@dineshkmr2696 жыл бұрын
Thank you so so much for this video ... it works flawlessly
@RaghavPal6 жыл бұрын
You're welcome Dinesh
@suma4m3 жыл бұрын
13:46 Very important part. If you don't put package name after "logger.file.name=", your log file will come out empty!
@RaghavPal3 жыл бұрын
Thanks for adding Marek
@rahulshinde4373 жыл бұрын
@@RaghavPal what if i don't want to pass package as i have multiple package how can i handle it
@siddeshb.b46173 жыл бұрын
Correct
@100janyam Жыл бұрын
What should I do if my run as shows only 'Run Configurations', but no Java application?
@RaghavPal Жыл бұрын
Sowjanya If your Run As menu in Eclipse IDE only shows "Run Configurations", but no Java application, here are a few things you can do: 1. Make sure that the Java project is properly configured. You can do this by right-clicking on the project and selecting "Properties". In the Properties window, select the "Run/Debug" tab and make sure that the "Project JDK" and "Project SDK" are set to the correct versions. 2. Make sure that the Java application is executable. You can do this by right-clicking on the Java file and selecting "Run As" > "Java Application". If the application does not start, it is likely not executable. 3. Make sure that the Java application is selected in the Run As menu. You can do this by clicking on the "Run Configurations" menu and selecting the Java application from the list. 4. If you are still having trouble, you can try creating a new Java project and see if that fixes the problem. Here are some additional things to check if you are still getting the error: * Make sure that the Java project is open. * Make sure that the Java application is in the project's source folder. * Make sure that the Java application has a main method. * Make sure that the Java application is not a library project. If you are still having trouble, you can try the following: 1. Restart Eclipse IDE. 2. Clear the Eclipse IDE cache. 3. Uninstall and reinstall Eclipse IDE. If you are still having trouble, please contact Eclipse support for help. Here are the steps on how to clear the Eclipse IDE cache: 1. Open Eclipse IDE. 2. Go to "Window" > "Preferences". 3. In the Preferences window, select "General" > "Workspace". 4. Click on the "Clear Cache" button. 5. Click on the "Apply" button and then the "OK" button. I hope this helps!
@siddeshb.b46173 жыл бұрын
HI Raghav, MyLog file got created after program execution. but nothing is writing there. I can see logs only in console. Please help me on this. Note: I am not using Maven instead Java Project only.
@RaghavPal3 жыл бұрын
Hi Siddesh, I will need to check, will update
@itguyappnweb3011 Жыл бұрын
your sessions are very useful a querry :--- though I set levels to trace still log file is empty as it work on level off
@RaghavPal Жыл бұрын
will need to check on this
@itguyappnweb3011 Жыл бұрын
@@RaghavPal yes please
@mehakverma34006 жыл бұрын
Great work Raghav. Very well explained :)
@RaghavPal6 жыл бұрын
Thanks Mehak
@sumanshekhar37413 жыл бұрын
Loved the simple explanation, it would have been nice if this video covered the .xml config file also as that is widely used in industry.
@RaghavPal3 жыл бұрын
Noted Suman
@PBidwai5 жыл бұрын
how did you use that properties file? I don't see that file being used anywhere in your code.
@RaghavPal5 жыл бұрын
Hi Pratik, pls check earlier videos - kzbin.info/aero/PLhW3qG5bs-L8oRay6qeS70vJYZ3SBQnFa
@PBidwai5 жыл бұрын
Oh thanks...
@seemanelogal5 жыл бұрын
@@PBidwai can i know the video number or the name from the link Raghav posted for u?
@seemanelogal5 жыл бұрын
@@RaghavPal can i please know either video number or name of the topic in your video?
@PBidwai5 жыл бұрын
Its playlist: kzbin.info/aero/PLhW3qG5bs-L8oRay6qeS70vJYZ3SBQnFa
@Arunganesan14 жыл бұрын
Hi Raghav, When I run the same code, I’m not getting any error but still log folder is not generated and also I got only logger.error and logger.fatal messages but not getting info and warn messages. Could you please suggest me? Thanks.
@RaghavPal4 жыл бұрын
Hi Rahul, try a diff ver, Also recheck that you followed all the steps
@RaghavPal4 жыл бұрын
Hi Rahul, try a diff ver, Also recheck that you followed all the steps
@navya14336 ай бұрын
hi. i am facing same error. can you tell me what worked with you?
@udangng4 жыл бұрын
Hey Raghav, Nice explanation but I would like to know more when you said around 7:45ish that we can use the logger wherever/wherever we want in our class. My question is why cannot we use "System.out.println..." command than using a logger? Is there a significance over "System.out.println..."command?
@RaghavPal4 жыл бұрын
Hi Udai, When you add loggers, you can control the logs levels like error, warning, information, etc and can get more useful information for troubleshooting
@brandonflorida10926 жыл бұрын
Beautifully clear. Thank you so much!
@RaghavPal6 жыл бұрын
You're welcome
@meghanamule16452 жыл бұрын
Hi, I cant make logs folder in application after running application . even I set the log4j.properties ??
@RaghavPal2 жыл бұрын
will need to check the setup Meghana, try some online examples
@vjkrish473 жыл бұрын
Hi Raghav sir, y we have to create Log4jDemo package in src/main/java...we wont add in src/test/java. one more,Log4j2.properties file ,if we keep in src/main/java or src/main/resources,then only logs folder creating and printing in the console also,if we keep other place its not working.. we should not keep in the src folder -under Libraries. if we keep in src folder ,how can use it in program,is there any logic,please help me Raghav sir...
@RaghavPal3 жыл бұрын
I will plan a session on project structure
@madhavilatha19963 жыл бұрын
@@RaghavPal Thank you soo much...waiting for that..
@vigneshelan87163 жыл бұрын
log folder generating but inside log files i am not able to see logs any guess?
@RaghavPal3 жыл бұрын
Hi Vignesh, will need to see log4j setup and settings file
@vaishalijillewar74375 жыл бұрын
Helpful
@RaghavPal5 жыл бұрын
Thanks for watching Vaishali
@radhasubbu74762 жыл бұрын
Hi Raghav, Thanks for this video which is generating logs for one of the class only. But If we want to generate for multiple classes then?? how dynamically we call this logger class / object? Please comment on this.
@RaghavPal2 жыл бұрын
Hi Radha, I will try to do session on that, for now you can check some examples online
@ilavarasansriraman41404 жыл бұрын
Thanks guru ❤😊✨
@RaghavPal4 жыл бұрын
Always welcome Ilavarasan
@dhruv19734 жыл бұрын
Hi Raghav, it creates the file when run from the eclipse but does not generate file at the specified path when run using jar. Do you know why? Any other setting needs to be done? Like I gave the path appender.file.fileName=C:\\Maven_Log4JTest\\MyLogs.log. It generates the log file when run in eclipse but not using jar.
@RaghavPal4 жыл бұрын
Hi Dhruv, can you provide the time in the video so I can check exactly what part are you facing problem with
@yehenandaraweera15334 жыл бұрын
Thank you !!!. clearly understood
@RaghavPal4 жыл бұрын
Glad it helped Yehen
@uhsay19864 жыл бұрын
Hello Raghav, how do we add comments in .properties file ?
@RaghavPal4 жыл бұрын
Hi Yash, can use #
@kumarsaurav96604 жыл бұрын
thank u so much exactly what i am finding
@RaghavPal4 жыл бұрын
Glad I could help Kumar
@anchalpal77355 жыл бұрын
thank you for a helpful video
@RaghavPal5 жыл бұрын
You're welcome Anchal
@mboyi60142 жыл бұрын
Hi Raghav thanks for this tutorial. I'm facing an issue my consol logs are generating. My file is also generating but inside file there are no logs appearing. could you please help me.
@RaghavPal2 жыл бұрын
Hi, will need to check your setup, check some log4j example and try with that
@mohammadrasheed84024 жыл бұрын
How to use Log4j in full-fledged selenium framework? As you used demo package in your example while in a framework there are multiple packages. Other than this do we not require to read the property file?
@RaghavPal4 жыл бұрын
You can setup log4j in a separate class and then use it wherever you want to add logs
@akhilakandukuri474 жыл бұрын
Thanks for the video..really helpful. Is it mandatory to place log4j2.properties only inside src/main/resources
@RaghavPal4 жыл бұрын
not mandatory
@shilupg5 жыл бұрын
Wats the use of Log4, if we have extend report, whether both should be required, can we use the logger message in extend report
@RaghavPal5 жыл бұрын
Hi Shilu, It depends, If you want to output logs at diff levels, Log4J will be helpful. Some dev just like to add some print statements in their code as part of troubleshooting. You can use TestNG and Log4J together
@WorkWork-ed4vc2 жыл бұрын
My log file came out empty. I am following your steps on Maven Project with TestNg, not main method. I have lots of packages. I can I add package names in in log4j2.properties file?
@RaghavPal2 жыл бұрын
will need to check with more details, can try using some online examples
@aartiriat75904 жыл бұрын
Hi Raghav, I am using eclipse version 4.17. I am not able to find any compatible version of log4j for this. Could you please suggest any workaround? Thanks.
@RaghavPal4 жыл бұрын
Hi Aarti, how did you check the compatibility, Can you not update Eclipse ver
@aartiriat75904 жыл бұрын
I tried diff versions of log4j to work with eclipse . When i am trying to create logger object, it doesnt show any supporting libraries for getlogger
@RaghavPal4 жыл бұрын
okay, not sure if there can be some issue in the configurations. Can you separately try with a diff eclipse, Just to rule out Eclipse issues
@OdiaVlogsbyLipika4 жыл бұрын
Thanks for this video.
@RaghavPal4 жыл бұрын
You're welcome Odia
@ankitmehra9544 жыл бұрын
Nicely explained, If i want to generate a log file with current Timestamp as its name everytime we run the application How to do that
@RaghavPal4 жыл бұрын
Hi Ankit, this can help - stackoverflow.com/questions/44753863/log4j-properties-create-new-log-file-with-timestamp-for-every-run
@ankitmehra9544 жыл бұрын
Thanks for the prompt reply I have checked thisLink already But it doesn't seem to Help That much. Can you provide any other Solution. It will be really helpful.
@ankitmehra9544 жыл бұрын
I got a solution for this problem
@AutomationTesting-q7v19 күн бұрын
How can i include this logs in extent reports or any other HTML reports. ?
@RaghavPal18 күн бұрын
1. *Set up Log4j* : Configure `log4j.properties` to write logs to a file (e.g., `logs/test-log.log`). 2. *Generate Logs* : Use `Logger` in your tests: ```java log.info("Test started."); log.error("An error occurred."); ``` 3. *Read Logs in Code* : Create a method to read log content: ```java public String getLogsContent() throws IOException { return new String(Files.readAllBytes(Paths.get("logs/test-log.log"))); } ``` 4. *Add Logs to Report* : Use Extent Reports to include logs: ```java test.log(Status.INFO, "Logs: " + getLogsContent()); ``` 5. *Run Tests* : Logs will appear in the HTML report -
@SaraMohamed-ge7vg2 жыл бұрын
@Raghav Thank you for sharing such courses and knowledge 🤗 , I tried to apply the video steps but i got an error while accessing the log file generated stating ( Log format is not recognized ) and it doesn't log anything into it , do you suggest any solution ?
@RaghavPal2 жыл бұрын
pls check this stackoverflow.com/questions/63300617/getting-issue-in-intellij-with-log4j-log-file-format
@mounika46396 ай бұрын
I created class in src/test/java i am not getting a file and I tried in src/main/java then I try to run but it's showing run configuration is not showing java application
@RaghavPal6 ай бұрын
Mounika It seems you're encountering an issue with Eclipse not showing the "Run as Java Application" option. Let's troubleshoot this: 1. Check Your Main Class: - Ensure that your main class has the correct syntax for the `main` method: ```java public static void main(String[] args) { // Your code here } ``` - Make sure the `String[] args` parameter is included. 2. Create a New Run Configuration: - Right-click on your Java file. - Choose "Run As" > "Run Configurations." - Select "Java Application" and click "New." - Configure the run settings and click "Run." 3. Shortcut Method: - Place the cursor in your class. - Press `Alt + Shift + X` to open the context menu. - Press `J` to run as a Java application. Remember to check if your project is set up correctly and that Eclipse recognizes it as a source folder -
@tango3dublin2 жыл бұрын
Hi Raghav, I followed your step exactly as showed in video, but still I am not getting trace, info and warn logs as well as not getting "log" folder and MyLogs file as well. kindly let me know how to fix it?
@RaghavPal2 жыл бұрын
Hi Samuel, not sure if you missed something, I will suggest to check the official documentation or some online examples and try
@tango3dublin2 жыл бұрын
@@RaghavPal Thanks Raghav
@geekysantosh4 жыл бұрын
what is the difference between log4j and extentreports and which is better?
@RaghavPal4 жыл бұрын
Hi Santosh, log4j is to create logs at diff level, Extent reports is a reporting library
@nikitabobade15823 жыл бұрын
Hi Raghav, after running the test the log folder is not getting created. I am working on the framework implementation.
@RaghavPal3 жыл бұрын
Hi Nikita, will need to check the setup again
@nikitabobade15823 жыл бұрын
Thanks for the reply sir...but could you please explain how the log4j works with TestNg framework
@RaghavPal3 жыл бұрын
Hi Nikita, log4j is a logging library so we just added it for controlling the logs.
@istvan3684 жыл бұрын
Really helped me, thank you :)
@RaghavPal4 жыл бұрын
Glad to hear that István
@princemalik59174 жыл бұрын
Hi , Everything is running fine just an issue that mylogs.log file under log folder is coming empty. What should I do ?
@RaghavPal4 жыл бұрын
Hi Prince, can get some help here - stackoverflow.com/questions/15520014/log-file-is-created-but-file-is-empty
@tanmaykumbhar96144 жыл бұрын
Hi, im able to view the logs output on the console, but the same is not getting written in MyLogs.log file. Please help.
@RaghavPal4 жыл бұрын
Hi Tanmay, I will have to check your setup. You can try some online help meanwhile
@dhruv19734 жыл бұрын
You need to give the name of your package in logger.file.name= in properties file
@AmitSingh-nq5vp3 жыл бұрын
Thank you so much for this video but one question I have related to this... How we can generate different files in logs folder with timestamps...i want to implement in my framework
@RaghavPal3 жыл бұрын
Hi Amit, pls check stackoverflow.com/questions/44753863/log4j-properties-create-new-log-file-with-timestamp-for-every-run#:~:text=You%20need%20to%20write%20(or,file%20hits%20the%20size%20limit
@sarangmech5 жыл бұрын
Hi Raghav, is there any test automation framework for testing an existing logging framework used by developers in a project?
@RaghavPal5 жыл бұрын
Not sure on this Saranga
@venkatmungara180 Жыл бұрын
thank you
@RaghavPal Жыл бұрын
Most welcome
@tarunparashar75543 жыл бұрын
hello Raghav sir, I have added log4j2.properties file in my project but still it is showing fatal or error log message and not showing info and warn message moreover that its not generating log file. Kindly help me to resolve this issue.
@RaghavPal3 жыл бұрын
Hi Tarun, check the detailed logs and see the steps again
@tarunparashar75543 жыл бұрын
@@RaghavPal Thanks for your response Raghav. I have checked again but same result.is it required to set any path or any other configurations? Bcoz I think eclipse is not able to read log4j2.properties file
@tarunparashar75543 жыл бұрын
Kindly do the needful.
@mallikarjunaswamyb37655 жыл бұрын
Raghav also how can we generate the separate logs in parallel execution wit testng?
@RaghavPal5 жыл бұрын
You can write logs as you wish using the log4j functions
@DucNguyen-xn5bd5 жыл бұрын
Why we create class in main package Raghav? is this package any different with other?
@RaghavPal5 жыл бұрын
main is the starting point in java program. Whatever we need to run at the start can put in main
@rajeshbe22345 ай бұрын
Hi Sir, How to add AM PM along with the timestamp of log 4j
@RaghavPal5 ай бұрын
Rajesh Let's break down the problem step by step Step 1: Identify the configuration file Log4j configuration is usually defined in a file called `log4j.xml` or `log4j.properties`. We need to locate this file in our project. Step 2: Understand the current timestamp format Check the current timestamp format in the Log4j configuration file. It might look something like this: ```xml ``` In this example, the timestamp format is `yyyy-MM-dd HH:mm:ss`. Step 3: Modify the timestamp format To add AM/PM notation, we need to modify the timestamp format. We can use the `a` conversion character to include AM/PM in the timestamp. Update the pattern layout to: ```xml ``` Here, we've changed `HH` (24-hour clock) to `hh` (12-hour clock) and added the `a` conversion character to include AM/PM notation. Step 4: Save and test the changes Save the updated `log4j.xml` or `log4j.properties` file. Then, run your application and check the log output. The timestamp should now include AM/PM notation, like this: ``` 2023-03-16 02:45:00 PM [main] INFO com.example.MyLogger - This is a log message. ``` That's it! We've successfully added AM/PM notation to the timestamp of Log4j -
@rajeshbe22345 ай бұрын
@@RaghavPal Amazing thank you very much sir. I know you are the valid person to respond to your subscribers to reply like in this way I really appreciate that. I have been following you since 2018. You are such a nice person Raghav sir🫡😊
@subashtherider9623 жыл бұрын
Hi bro even while turning off log4j there's a file created under the log folder. is it possible to not create a file under the log folder
@RaghavPal3 жыл бұрын
Yes, you can
@subashr71983 жыл бұрын
@@RaghavPal how can you guide me
@RaghavPal3 жыл бұрын
I will check, will try to add some session on this but for now, you will need to take online help
@100janyam Жыл бұрын
Why did we create this demo in src/main and not in src/test?
@RaghavPal Жыл бұрын
could have done that, you can continue in src/test
@shivam14274 жыл бұрын
Doesn't work in Intellij. I just get the log.error displayed which is the default configuration. log.debg and log.info doesn't work. It only works when I place the log4j2.xml in the same path as my class files. It doesnt' work when it is placed anywhere else? I think it needs to be added to the build path. But I don't see an option in IntelliJ to add that resources/log4j2.xml in build path
@RaghavPal4 жыл бұрын
Ok Shivam, I will check on this, Not sure for IntelliJ
@karandeepsingh50006 жыл бұрын
How can we change the time of logs to any particular timezone ? I think currently it is taking local time of the your machine
@RaghavPal6 жыл бұрын
This should help stackoverflow.com/questions/9116425/apache-log4j-logging-with-specific-timezone logging.apache.org/log4j/1.2/faq.html#a3.4
@karandeepsingh50006 жыл бұрын
Automation Step by Step - Raghav Pal Thanks a lot bro
@RaghavPal6 жыл бұрын
You're welcome
@akashpatil50864 жыл бұрын
what we learn is log4j or log4j2? plz clear m confused sir?
@RaghavPal4 жыл бұрын
Hi Akash, this is a logging library to create and show logs during execution
@WorkWork-ed4vc2 жыл бұрын
You have Maven Project. Why did you do this with main method?
@RaghavPal2 жыл бұрын
Pls refer the time stamp in video for me to refer
@Vinodmhetre0074 жыл бұрын
It was a helpful video but you should have first created config files, it was confusing at the beginning, really. There was no need to create first java class.
@RaghavPal4 жыл бұрын
Thanks for the tip! I will improve
@alyda41024 жыл бұрын
Топ индус, уважаю
@RaghavPal4 жыл бұрын
Большое спасибо. Униженный
@AmitRanjan3 жыл бұрын
Liked
@RaghavPal3 жыл бұрын
Thanks Java
@tahaansari56213 жыл бұрын
Hi, very helpful video. Hats off! I have a question though, how can I make different levels of logging for console and file in the same property file? E.g. I'd like to use debug level of logging for file but for console I'd like to have info level logging. P.S. this was an incredible video. Thank you!
@RaghavPal3 жыл бұрын
Hi Taha, I will need to check on this, Will update if I find something. Thanks for watching
@tahaansari56213 жыл бұрын
@@RaghavPal okay, I'll wait.
@ravindramedagam25065 жыл бұрын
Thank you so much bro
@RaghavPal5 жыл бұрын
You're welcome
@stutiswarnkar51476 жыл бұрын
After writing the .properties file. All its components are showing as unused. What to do?
@RaghavPal6 жыл бұрын
Hi Stuti, have you referred them in your scripts. It should be fine if not creating any error
@deekshatewari48236 жыл бұрын
log folder is not getting created automatically
@RaghavPal6 жыл бұрын
Will have to check. Pls also verify with the video, you did not miss any step
@santhosh76425 жыл бұрын
you might have missed selenium dependencies
@AbhishekChauhan-id7rc4 жыл бұрын
Yes Raghav, Log folder is not being created . followed all the steps as per expected. Could you please tell the workaround for it.
@prabhudevan90345 жыл бұрын
Log4j2.properties remains same for every project?
@RaghavPal5 жыл бұрын
You can use multiple files Prabhu
@tejkumarkempaiah63805 жыл бұрын
Raghav, Can you please add Implementing Log4J into Framework having TestBase or something similar ?
@RaghavPal5 жыл бұрын
Hi Tej, will need more info/details on your needs
@tejkumarkempaiah63805 жыл бұрын
@@RaghavPal : How to implement Extent Report and Log4J as part of Framework. Like there is a Class called TestBase, Which Implements ITestListener And we have 4 test cases to be executed(TC01, TC02, TC03, TC04) where all of them extends to TestBase so that extent Reports and Log4J properties can be utilized across all the test cases.. Kindly let me know if I have provided clear information.
@RaghavPal5 жыл бұрын
Okay I will add more sessions related to this
@tejkumarkempaiah49065 жыл бұрын
@@RaghavPal : Thank you
@tejkumarkempaiah49065 жыл бұрын
@@RaghavPal In fact, Please add implementation of Log4j and Extent Reports from Framework point of view for Selenium. That will be very useful as there no much info available for the same. Will be eagerly waiting for the reply, videos :)
@Last_30_Seconds2 жыл бұрын
After refreshed project not getting log folder please let me know why??
@RaghavPal2 жыл бұрын
Hi Salman, not sure if any setup or step was missed, I can suggest to check and try all steps again and if you still face issue can try checking online
@Last_30_Seconds2 жыл бұрын
@@RaghavPal thanks Sir already tried but still not solved i will check again.
@ashwinidongare4147 Жыл бұрын
How to overrite the file. Instead of appending
@RaghavPal Жыл бұрын
Hi Ashwini Here are the steps on how to overwrite the log file in your Java project that uses Log4j: 1. Open your log4j configuration file. 2. Find the `appender` element that you want to overwrite. 3. Set the `append` attribute to `false`. 4. Save your configuration file. For example, if you have a log4j configuration file that looks like this: ``` ``` To overwrite the log file instead of appending, you would need to change the `append` attribute of the `file` appender to `false`. The updated configuration file would look like this: ``` ``` Once you have saved your configuration file, the log file will be overwritten each time the application is run. I hope this helps
@meenu11073 жыл бұрын
Log folder is not created in my project , what should i do?
@RaghavPal3 жыл бұрын
Check the setup again Chhavi
@hboulahya4 жыл бұрын
Using log4j-1.2.17 jar file Im getting error og4j:WARN No appenders could be found for logger (className log4j:WARN Please initialize the log4j system properly. Please advise!!
@RaghavPal4 жыл бұрын
Hi Hicham, pls check this stackoverflow.com/questions/12532339/no-appenders-could-be-found-for-loggerlog4j
@DucNguyen-xn5bd5 жыл бұрын
Why we need Log4j Raghav, it just display log in test run. We also can make log by TestNG or extent report, it more convenience than Log4j only.
@RaghavPal5 жыл бұрын
There are diff ways for logging. TestNG will be good for logging test related events. If your need if met using TestNG. you can skip log4j
@marcscherzer3 жыл бұрын
Are log4j and log4js same?
@RaghavPal3 жыл бұрын
Hi Marc, log4js is different, check www.npmjs.com/package/log4js