Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Hemanth KumarKumar
Greenhorn
Posts: 2
  • 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

 
Salil Wadnerkar
Ranch Hand
Posts: 91
  • 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: 2
  • 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: 91
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!