wood burning stoves 2.0*
The moose likes Other Open Source Projects and the fly likes creating a log file for my servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "creating a log file for my servlet" Watch "creating a log file for my servlet" New topic
Author

creating a log file for my servlet

shyamkumar bopannachengalaiah
Ranch Hand

Joined: Dec 30, 2008
Posts: 100
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.











amit punekar
Ranch Hand

Joined: May 14, 2004
Posts: 511
Hi,
You can use Log4j APIs to log the required statements to log file.

Regards,
Amit
shyamkumar bopannachengalaiah
Ranch Hand

Joined: Dec 30, 2008
Posts: 100
I dont know how can i use log4j. Can you give me a example?
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3816

Official Log4j documentation contains details of diffrent ways you can configure log4j (including inside a web application).


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
shyamkumar bopannachengalaiah
Ranch Hand

Joined: Dec 30, 2008
Posts: 100
The documentation is not opening . Kindly send me alternate link.
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3816

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.
Nandhakumar Soundarrajan
Greenhorn

Joined: Apr 24, 2009
Posts: 23
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.


Thanking the green horns sincerely,
Nandha
amit punekar
Ranch Hand

Joined: May 14, 2004
Posts: 511
Hi,
This may help you about log4j understanding.

log4j Article
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: creating a log file for my servlet
 
Similar Threads
Converting Excel data table in to XML format
Reading text in a table from word document
HWPF POI
prepared statement in for loop
Apache HSSF - corrupt excel file