Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Logging not working

 
Srikanth Madasu
Ranch Hand
Posts: 48
Eclipse IDE Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying a small application everything works fine except the logging.... I used the following code...

log4j.rootLogger=ALL, stdout

log4j.appender.stdout=org.apache.log4j.RollingFileAppender
log4j.appender.stdout.File=C:\Program Files\apache-tomcat-6.0.18\logs\struts-example-log.log
log4j.appender.stdout.MaxFileSize = 100KB
log4j.appender.stdout.MaxBackupIndex = 1
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} - %p %c - %m%n

And in my action I am using the code...

private static Log log = LogFactory.getLog("com.ex.actions.LogonAction");

and using log as:

log.debug("Login successful!!");


And I put the log4j.jar in WEB-INF\lib.

I was expecting that it would create a log file in the specified location and write to it. But it did not.

I tried creating an empty log file in that location but no use :-(

I am trying to deploy on tomcat server. Can anyone tell me where I am doing wrong.

Also does it matter where the file logging.properties file is placed?

Am I missing something? I will be thankful if anyone can help me.. Thanks in advance

--Srik.
 
Alejandro Galvan
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

First, seems that this is not the correct forum, but right now I can not think in a proper forum.

I suppose you also have the commons-logging jar in your WEB-INF/lib folder. The code you are using:

is from commons-logging API, not from Log4j.

The normal way to get the logger for Log4j is:


Go to the Log4j Manual site and read more about.

Hope this helps you.


Regards,
 
Srikanth Madasu
Ranch Hand
Posts: 48
Eclipse IDE Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alejandro, thanks for your reply. Yes I do have commons-logging.jar in my WEB-INF\lib. I tried using both log4j and commons logger. but still no use. I don't know what I am missing.

And my doubt about placing the logging.properties files, is there any particular location this file should reside? Because, when i googled for this there were some discussions of the location of this file on tomcat server.

thanks

--Srik
 
Alejandro Galvan
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

The default config file for Log4j should be named log4j.properties and must be placed on the root of the application's classpath, but Log4j is highly configurable, please refer to the page I previously gave you and go to the "Example Configurations" section. Also, if you want more help, maybe the rigth forum for this topic should be: "Other Open Source Projects", please go there and post your questions, since this seems not to be related to Struts.

Regards,
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic