Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Logging Error with Spring+Log4j

 
Rajkumar balakrishnan
Ranch Hand
Posts: 445
Android Eclipse IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where did you put log4j.properties ? Under WEB-INF ?
 
Rajkumar balakrishnan
Ranch Hand
Posts: 445
Android Eclipse IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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()?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is ${Erp} ? Where does it come from ?
 
Rajkumar balakrishnan
Ranch Hand
Posts: 445
Android Eclipse IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic