Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Log4j and resin  RSS feed

 
hanihanan younis
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all..
i face a probelm that i have many webapps under the resin & i make to every webapp separate .log file for it...
it work correclty..but at the server..sometimes it there are conflicting that webapp write its log in others & so on..
if i can make like a listener to every webapp to confirm the logging for it..need some expert advices. with thanx
 
Daniel Rhoades
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I create a Context listener and put my log setup code in there:

 
hanihanan younis
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i will be more than glad if you give more details about that..im new to the contextlistener..& what i should put in web.xml ...
please give me more detail
wether you reply or not..
im great thankfull to you..coz you give me the key of solution..& i hope this soultion is guaranteed coz it is urgent to me as a fresh developer in my company..
thank you a lot
 
Daniel Rhoades
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm feeling generous today, so here is a very simple container independant solution...

Listener class looks like this:



web.xml extract:



config.properties (Log4j config file) looks like this:



Then in your servlet you log like this:



In a nutshell thats about it, I'm sure there is a more comprehensive guide on the log4j website.

Better solutions include encapsulting logging into another class, then use that in your app - that way if you change your logger you don't have to re-write your classes
 
hanihanan younis
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is really what i need..
you are so gentle with me..
this is tutorial from you & soultion..

thank you from my heart..

GOD BLESS YOU...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!