This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
Win a copy of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 this week in the Programmer Certification forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

log4j is printing only once at Start. unable to figure out the issue, please help

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,

I am using log4j for quite some time but I am stuck with some issue that is not getting resolved.

We have a servlet that is initializing log4j and when invoked for the first time, log4j logs are getting printed (this means its reading log4j config file) but when it's invoked for second time and so on, the logs are not getting printed. When I restart the server, this happens again and logs getting printed for the first time only.

Server: JBoss

log4j property file:

### direct log messages to stdout ###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
log4j.rootLogger=stdout,R
#### Second appender writes to a file# file appender
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=<FILEPATH>
log4j.appender.R.MaxFileSize=20MB
log4j.appender.R.MaxBackupIndex=5
log4j.appender.R.threshold=INFO
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n

Servlet Class:


Ideally for all the requests, START TIME, END TIME and other statements should get printed but it's not happening. Am I missing something here? Please help.

Regards,
Pankaj
 
author
Posts: 3281
8
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there can you please edit your post? e.g. UseCodeTags That's help us read your post
 
PankajKumar jaiswal
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Martijn,

Updated the post to put code in code tags but still the problem is not solved. Any help is appreciated.
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you sure the doGet method is actually being called multiple times?
 
PankajKumar jaiswal
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, because we are getting response every time. We have some validation logic for the input data and some DB operations and then it returns message in the form of XML message. When we change the input data, its working as expected like giving error msg, success, failure etc... only concern is with the logs not printing in the file that will make it hard for debugging in case of any issue.
 
PankajKumar jaiswal
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok the problem is resolved. When I was creating war file it was including some CVS folders... i unzipped it, removed all the unwanted CVS folders and created war again and it started working. However, I am still clueless as what those CVS folders have to do with logging at all....
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

PankajKumar jaiswal wrote:However, I am still clueless as what those CVS folders have to do with logging at all....



So am I. My guess is that it had nothing to do with the CVS files. It probably is a co-incidence that you got it working when the CVS files were removed.

 
That which doesn't kill us makes us stronger. I think a piece of pie wouldn't kill me. Tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!