• 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
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

Log4j From Thread is not writing to Log File but writing to Console  RSS feed

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a web application with multi threading. Application flow is in such a way that certain classes uses multithreading and am using FutureTask for it. I have to generate a log in one of the classes which is invoked by each thread.

If I do Logger employeeLog = Logger.getLogger("Employee"); in classes which are not executed by a Thread the logs are written to the file.

If I use same initialization Logger employeeLog = Logger.getLogger("Employee"); in classes which are part of the thread, the logs are written to console but not appending to a file.

Below is my log4j.xml

 
Ranch Hand
Posts: 104
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using a different classloader in your FutureTask callable, which loads files from different classpath? log4j, by default, takes its configuration from the log4j.xml in the classpath.
 
Hemanth KumarKumar
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Salil Wadnerkar wrote:Are you using a different classloader in your FutureTask callable, which loads files from different classpath? log4j, by default, takes its configuration from the log4j.xml in the classpath.



Hi Salil - No, am not loading log4j again in FutureTask callable.

In my init servlet of application I do this :


and in CustomLoggerWrapper
 
Salil Wadnerkar
Ranch Hand
Posts: 104
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!