Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 12th, 2007, 03:18 AM
stanley1610's Avatar
stanley1610 stanley1610 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 267 stanley1610 User rank is Sergeant (500 - 2000 Reputation Level)stanley1610 User rank is Sergeant (500 - 2000 Reputation Level)stanley1610 User rank is Sergeant (500 - 2000 Reputation Level)stanley1610 User rank is Sergeant (500 - 2000 Reputation Level)stanley1610 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 18 h 30 m 11 sec
Reputation Power: 14
Log4j.properties

I created the following log4j.properties in /WEB-INF/classes/

Code:
# For JBoss: Avoid to setup Log4J outside $JBOSS_HOME/server/default/deploy/log4j.xml!
# For all other servers: Comment out the Log4J listener in web.xml to activate Log4J.
log4j.rootLogger=INFO, stdout, logfile

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n

log4j.appender.logfile=org.apache.log4j.RollingFileAppender
log4j.appender.logfile.File=C:/Temp/springapp.log
log4j.appender.logfile.MaxFileSize=512KB
# Keep three backup files.
log4j.appender.logfile.MaxBackupIndex=3
# Pattern to output: date priority [category] - message
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - %m%n


However, no springapp.log is generated at all. Is there any additional configuration required? Thanks.
__________________
------------------------------------------
Perl Kids Kiss Perl
Stanley
------------------------------------------

Reply With Quote
  #2  
Old February 12th, 2007, 07:48 AM
crownjewel82 crownjewel82 is offline
rebel with a cause
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: May 2004
Location: The Batsh!t Crazy State.
Posts: 5,766 crownjewel82 User rank is General 34th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 34th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 34th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 34th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 34th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 34th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 34th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 34th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 34th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 34th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 34th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 34th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 34th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 34th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 34th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 34th Grade (Above 100000 Reputation Level)  Folding Points: 53188 Folding Title: Beginner FolderFolding Points: 53188 Folding Title: Beginner FolderFolding Points: 53188 Folding Title: Beginner Folder
Time spent in forums: 3 Months 3 Days 15 h 56 m 28 sec
Reputation Power: 3229
How are you loading the properties file?
__________________
Resistance to tyrants is obedience to God. - Thomas Jefferson

Reply With Quote
  #3  
Old February 12th, 2007, 12:04 PM
stanley1610's Avatar
stanley1610 stanley1610 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 267 stanley1610 User rank is Sergeant (500 - 2000 Reputation Level)stanley1610 User rank is Sergeant (500 - 2000 Reputation Level)stanley1610 User rank is Sergeant (500 - 2000 Reputation Level)stanley1610 User rank is Sergeant (500 - 2000 Reputation Level)stanley1610 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 18 h 30 m 11 sec
Reputation Power: 14
I am not sure, how can I check?

In the same folder, there is a Resource Bundle file called messages.properties. It works.

Reply With Quote
  #4  
Old February 12th, 2007, 12:48 PM
Yawmark's Avatar
Yawmark Yawmark is offline
Feelin' Groovy
Dev Shed God 8th Plane (8500 - 8999 posts)
 
Join Date: Aug 2001
Location: WDSMIA
Posts: 8,628 Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 3 Weeks 3 Days 8 h 30 m
Reputation Power: 2097
Send a message via ICQ to Yawmark Send a message via MSN to Yawmark
Quote:
Comment out the Log4J listener in web.xml to activate Log4J.

Did you do this?

~
__________________
Yawmark
class Sig{public static void main(String...args){\u0066or(int
\u0020$:"vÌÈÊ\"¤¾Àʲ¬Æ\"v¤Î¤\"²¤¨¸¬Æ".to\u0043h\u0061rArray()
)System./*goto/*$/%\u0126//^\u002A\u002Fout.print((char)(($>>
+(~'"'&'#'))+('<'>>('\\'/'.')/\u002Array.const(~1)\*\u002F)));}}

Reply With Quote
  #5  
Old February 12th, 2007, 03:22 PM
crownjewel82 crownjewel82 is offline
rebel with a cause
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: May 2004
Location: The Batsh!t Crazy State.
Posts: 5,766 crownjewel82 User rank is General 34th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 34th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 34th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 34th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 34th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 34th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 34th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 34th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 34th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 34th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 34th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 34th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 34th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 34th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 34th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 34th Grade (Above 100000 Reputation Level)  Folding Points: 53188 Folding Title: Beginner FolderFolding Points: 53188 Folding Title: Beginner FolderFolding Points: 53188 Folding Title: Beginner Folder
Time spent in forums: 3 Months 3 Days 15 h 56 m 28 sec
Reputation Power: 3229
Normally I use the PropertyConfigurator to load log4j properties files. But it can be done through the classpath and through xml configuration files as your comment seems to suggest.

Reply With Quote
  #6  
Old February 12th, 2007, 08:02 PM
stanley1610's Avatar
stanley1610 stanley1610 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 267 stanley1610 User rank is Sergeant (500 - 2000 Reputation Level)stanley1610 User rank is Sergeant (500 - 2000 Reputation Level)stanley1610 User rank is Sergeant (500 - 2000 Reputation Level)stanley1610 User rank is Sergeant (500 - 2000 Reputation Level)stanley1610 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 18 h 30 m 11 sec
Reputation Power: 14
It seems so. In the comment, there is "Comment out the Log4J listener in web.xml to activate Log4J."

Should there be somewhere else to activate Log4J in web.xml? Please advise. Thanks.

Reply With Quote
  #7  
Old February 13th, 2007, 09:07 AM
Yawmark's Avatar
Yawmark Yawmark is offline
Feelin' Groovy
Dev Shed God 8th Plane (8500 - 8999 posts)
 
Join Date: Aug 2001
Location: WDSMIA
Posts: 8,628 Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 3 Weeks 3 Days 8 h 30 m
Reputation Power: 2097
Send a message via ICQ to Yawmark Send a message via MSN to Yawmark
Quote:
Should there be somewhere else to activate Log4J in web.xml? Please advise. Thanks.

Check the web.xml for a Log4jListener. You may also try specifying a Log4JConfigListener in your deployment descriptor (web.xml).

~

Reply With Quote
  #8  
Old February 13th, 2007, 08:56 PM
stanley1610's Avatar
stanley1610 stanley1610 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 267 stanley1610 User rank is Sergeant (500 - 2000 Reputation Level)stanley1610 User rank is Sergeant (500 - 2000 Reputation Level)stanley1610 User rank is Sergeant (500 - 2000 Reputation Level)stanley1610 User rank is Sergeant (500 - 2000 Reputation Level)stanley1610 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 18 h 30 m 11 sec
Reputation Power: 14
the file /WEB-INF/classes/log4j.properties should be called automatically, shouldn't it?

Reply With Quote
  #9  
Old February 14th, 2007, 07:12 AM
Yawmark's Avatar
Yawmark Yawmark is offline
Feelin' Groovy
Dev Shed God 8th Plane (8500 - 8999 posts)
 
Join Date: Aug 2001
Location: WDSMIA
Posts: 8,628 Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 3 Weeks 3 Days 8 h 30 m
Reputation Power: 2097
Send a message via ICQ to Yawmark Send a message via MSN to Yawmark
Quote:
the file /WEB-INF/classes/log4j.properties should be called automatically, shouldn't it?

Not necessarily, and apparently not in your case. Is there some reason you don't want to configure an appropriate listener?

~

Reply With Quote
  #10  
Old February 14th, 2007, 09:49 PM
stanley1610's Avatar
stanley1610 stanley1610 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 267 stanley1610 User rank is Sergeant (500 - 2000 Reputation Level)stanley1610 User rank is Sergeant (500 - 2000 Reputation Level)stanley1610 User rank is Sergeant (500 - 2000 Reputation Level)stanley1610 User rank is Sergeant (500 - 2000 Reputation Level)stanley1610 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 18 h 30 m 11 sec
Reputation Power: 14
Quote:
Originally Posted by Yawmark
Not necessarily, and apparently not in your case. Is there some reason you don't want to configure an appropriate listener?

~

I did it now but I cannot deploy the application. Please help advise. Thanks.

Error:
Code:
log4j:WARN No appenders could be found for logger (org.springframework.web.context.support.XmlWebApplicationContext).
log4j:WARN Please initialize the log4j system properly.
2007-02-15 11:30:42,894 ERROR [org.apache.catalina.core.StandardContext] - <Error listenerStart>
2007-02-15 11:30:42,894 ERROR [org.apache.catalina.core.StandardContext] - <Context [/springapp] startup failed due to previous errors>


web.xml:
Code:
	<context-param>
		<param-name>log4jConfigLocation</param-name>
		<param-value>/WEB-INF/classes/log4j.properties</param-value>
	</context-param>
	<listener>
	   <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>	
	<listener>
	   <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
	</listener>

Reply With Quote
  #11  
Old February 15th, 2007, 07:16 AM
Yawmark's Avatar
Yawmark Yawmark is offline
Feelin' Groovy
Dev Shed God 8th Plane (8500 - 8999 posts)
 
Join Date: Aug 2001
Location: WDSMIA
Posts: 8,628 Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level)Yawmark User rank is General 17th Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 3 Weeks 3 Days 8 h 30 m
Reputation Power: 2097
Send a message via ICQ to Yawmark Send a message via MSN to Yawmark
Quote:
Please help advise. Thanks.

At this point, I'm just guessing. So I can provide better assistance, please provide the complete details of your configuration in its current state; i.e., web framework and version, servlet container and version, full web.xml and log4j configuration files, deployment structure, file locations, etc.

~

Reply With Quote
  #12  
Old February 15th, 2007, 09:39 PM
stanley1610's Avatar
stanley1610 stanley1610 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 267 stanley1610 User rank is Sergeant (500 - 2000 Reputation Level)stanley1610 User rank is Sergeant (500 - 2000 Reputation Level)stanley1610 User rank is Sergeant (500 - 2000 Reputation Level)stanley1610 User rank is Sergeant (500 - 2000 Reputation Level)stanley1610 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 18 h 30 m 11 sec
Reputation Power: 14
I followed the below example to set up log4j but failed.
http://www.springframework.org/docs/MVC-step-by-step/Spring-MVC-step-by-step-Part-1.html

So I set up log4jConfigLocation later
then my log file springapp.log appeared but get the error posted in the previous post and I cannot start my web application.

Thanks.

Reply With Quote
  #13  
Old February 23rd, 2007, 03:02 AM
stanley1610's Avatar
stanley1610 stanley1610 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 267 stanley1610 User rank is Sergeant (500 - 2000 Reputation Level)stanley1610 User rank is Sergeant (500 - 2000 Reputation Level)stanley1610 User rank is Sergeant (500 - 2000 Reputation Level)stanley1610 User rank is Sergeant (500 - 2000 Reputation Level)stanley1610 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 18 h 30 m 11 sec
Reputation Power: 14
Finally I solved the problem. Let me share the key here:

Part of web.xml:
Code:
	<context-param>
		<param-name>webAppRootKey</param-name>
		<param-value>springapp.root</param-value>
	</context-param>
	<context-param>
		<param-name>log4jConfigLocation</param-name>
		<param-value>/WEB-INF/classes/log4j.properties</param-value>
	</context-param>
<listener><listener-class>org.springframework.web.util.Log4jConfigListener</listener-class></listener>


That's all. Thanks.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > Log4j.properties


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT