Forums Register Login

creating a log file for my servlet

+Pie Number of slices to send: Send
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.











+Pie Number of slices to send: Send
Hi,
You can use Log4j APIs to log the required statements to log file.

Regards,
Amit
+Pie Number of slices to send: Send
I dont know how can i use log4j. Can you give me a example?
+Pie Number of slices to send: Send
Official Log4j documentation contains details of diffrent ways you can configure log4j (including inside a web application).
+Pie Number of slices to send: Send
The documentation is not opening . Kindly send me alternate link.
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
Hi,
This may help you about log4j understanding.

log4j Article
You guys haven't done this much, have ya? I suggest you study this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1655 times.
Similar Threads
Converting Excel data table in to XML format
HWPF POI
Apache HSSF - corrupt excel file
Reading text in a table from word document
prepared statement in for loop
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 16:44:01.