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

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
 
Anything worth doing well is worth doing poorly first. Just look at this tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!