• 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

Using LogManager

 
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my servlet init() code, I created some Logger objects and registered them with a LogManager using:

(class variable)
private final static LogManager logMgr = LogManager.getLogManager();

(in init() method)
Logger classLogger = Logger.getLogger("loggername"); logMgr.addLogger(classLogger);

Then my servlet calls an action class which has as a class variable:

private static Logger logger = LogManager.getLogManager().getLogger("loggername");

and my action class then logs messages using

logger.info("Message to log...");

I deployed this code on a single server and it worked fine. Then I deployed it on a clustered environment and whenever I tried to retrieve the Logger from the LogManager, it was null, and gave a null pointer exception.

Why in a clustered environment do I not have access to the same LogManager object as my servlet? Is this a classLoader problem? How would I be able to register my Loggers with a LogManager that can be accessed from any module - web or ejb?

Thanks Brian
 
If you were a tree, what sort of tree would you be? This tiny ad is a poop beast.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic