• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Logging not working

 
Ranch Hand
Posts: 50
Hibernate Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 50
Hibernate Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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,
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic