|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
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 ------------------------------------------ |
|
#2
|
|||
|
|||
|
How are you loading the properties file?
__________________
Resistance to tyrants is obedience to God. - Thomas Jefferson |
|
#3
|
||||
|
||||
|
I am not sure, how can I check?
In the same folder, there is a Resource Bundle file called messages.properties. It works. |
|
#4
|
||||
|
||||
|
Quote:
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)));}} |
|
#5
|
|||
|
|||
|
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.
|
|
#6
|
||||
|
||||
|
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. |
|
#7
|
||||
|
||||
|
Quote:
Check the web.xml for a Log4jListener. You may also try specifying a Log4JConfigListener in your deployment descriptor (web.xml). ~ |
|
#8
|
||||
|
||||
|
the file /WEB-INF/classes/log4j.properties should be called automatically, shouldn't it?
|
|
#9
|
||||
|
||||
|
Quote:
Not necessarily, and apparently not in your case. Is there some reason you don't want to configure an appropriate listener? ~ |
|
#10
|
||||
|
||||
|
Quote:
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> |
|
#11
|
||||
|
||||
|
Quote:
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. ~ |
|
#12
|
||||
|
||||
|
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. |
|
#13
|
||||
|
||||
|
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. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Java Help > Log4j.properties |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|