This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
Win a copy of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 this week in the Programmer Certification forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

creating a log file for my servlet

 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had develioped a application where inserting datas from Excel sheet to database.My problem is that when ever a duplicate value is developed either in database or excel sheet , i have to create a log file file and that duplicate value has to written in that log file.I had written the logic for printing the duplicate values in servlet using out.println. but i dont know how to create log file and to write this duplicate values there. Kindly help me.











 
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
You can use Log4j APIs to log the required statements to log file.

Regards,
Amit
 
shyamkumar bopannachengalaiah
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont know how can i use log4j. Can you give me a example?
 
Bartender
Posts: 4106
72
Hibernate Fedora Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Official Log4j documentation contains details of diffrent ways you can configure log4j (including inside a web application).
 
shyamkumar bopannachengalaiah
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The documentation is not opening . Kindly send me alternate link.
 
Vijitha Kumara
Bartender
Posts: 4106
72
Hibernate Fedora Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The link I gave directly pointing to the manual page which describes how to configure log4j. If you have downloaded the log4j distribution it also contains that under "site" folder once you extract it. BTW, I don't have any problem with the link.
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had a similar scenario and in my case I could not use log4j as I need to show the logs of import in a separate file.

In created a separate JAVA class which does importing, so I just call the import method in the class with the filename as parameter which adds all the log values either success or failed (starts with "INFO:" if succeeds and starts with "ERROR:" if fails) and this method returns the arraylist to the calling servlet.

In my servlet I just loop around the arraylist and print it to the brower (which shows only errors) and a log file (which captures all).

Hope this helps.
 
amit punekar
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
This may help you about log4j understanding.

log4j Article
 
Whatever you say buddy! And I believe this tiny ad too:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!