File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Spring and the fly likes Logging Error with Spring+Log4j Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Logging Error with Spring+Log4j" Watch "Logging Error with Spring+Log4j" New topic
Author

Logging Error with Spring+Log4j

Rajkumar balakrishnan
Ranch Hand

Joined: May 29, 2008
Posts: 445

I am using Log4j as my logger with Spring. I did everything as per the basic tutorial and tried to write log messages in a log file. But every attempt to this is failed

my web.xml file is


The log4j.properties file is



Then in my controller i wrote a code to add message to text file

No matter what, it's not working. but when i try to print it in console, its printing. Please help me where i went wrong?


Never try to be a hard-worker. Be a smart-worker.
My Blog
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Where did you put log4j.properties ? Under WEB-INF ?


[My Blog]
All roads lead to JavaRanch
Rajkumar balakrishnan
Ranch Hand

Joined: May 29, 2008
Posts: 445

Christophe Verré wrote:Where did you put log4j.properties ? Under WEB-INF ?


Yes it is under WEB-INF folder. As i said earlier there is no problem in detecting the prop file. Because the log messages got printed in console but when i try to write them to a file, it isn't writing. The log.txt file is also under WEB-INF.
Lorand Komaromi
Ranch Hand

Joined: Oct 08, 2009
Posts: 276
Rajkumar balakrishnan wrote:As i said earlier there is no problem in detecting the prop file. Because the log messages got printed in console


Which message? The one printed with System.out.println()?


OCJP 6 (93%)
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

What is ${Erp} ? Where does it come from ?
Rajkumar balakrishnan
Ranch Hand

Joined: May 29, 2008
Posts: 445

Lorand Komaromi wrote:
Which message? The one printed with System.out.println()?


Nope, logger.info(); Do you think i am that much dumb?

Christophe Verré wrote:What is ${Erp} ? Where does it come from ?


From web.xml. Have a look at this.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Logging Error with Spring+Log4j