You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by "Diehl Martin, Köln" <ma...@fja.com> on 2001/09/07 13:26:11 UTC

RE: Logging in a Multi threaded environment - EJB-Container

Hi,

how does this interact with the transparent thread handling in an
EJB-Container.
In such a situation, when the container handles the threads that use my
classes, do I have to fear dead lock situations?

I think the only case where there could be a problem is when we call any
bean method inside the logging-call, which could be the case if the message
itself performs such a call to be evaluated.
E.g:
logger.info("Withdrawing " + amount + " $ from account " +
anotherBean.getAccountName(id));

The EJB-Spec prohibits 'the use of thread synchronization primitives', but
explains that this is due to the fact that the container may distribute my
beans over more than one address spaces. In that case we wouldn't have a
problem since we would als have more than one category hierarchies.

Any comment on that?


> -----Original Message-----
> From:	Jon Skeet [SMTP:jon.skeet@peramon.com]
> Sent:	Thursday, September 06, 2001 3:01 PM
> To:	LOG4J Users Mailing List
> Subject:	RE: Logging in a Multi threaded environment
> 
> > Currently we are considering log4j for our application 
> > logger and so I have tried out the basic features of log4j ....
> 
> > But i have a doubt when i try to log in a multithreaded 
> > environment...DOES log4j PROVIDE A SYNCHRONIZED LOGGING MECHANISM?? 
> 
> Yes - or rather, it depends on the appender in question, but any
> appender inheriting from AppenderSkeleton (which most will) synchronize
> there.
> 
> > say a thread A is logging some message in a class at 
> > the same time when another thread of the same class is 
> > also busy logging!! In such an event my HO is that since 
> > the Category object that they share is a static one with 
> > the same name, messages from both the threads would go to 
> > the same Category object..am i right?
> 
> Yes.
> 
> > Also, consider a situation wherein my thread A has a big 
> > message and has called its cat.info(message)...similarly 
> > thread B had called its cat.info(message) but has only a 
> > smaller message. In such a case, which will appear first, 
> > say in my file if i use a FileAppender, message of thread A or B???
> 
> Whichever gets to the appender.doAppend() first.
> 
> Jon
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: log4j-user-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org


RE: Logging in a Multi threaded environment - EJB-Container

Posted by Ganapathi Raman <ma...@yahoo.com>.
 Hi Martin.
I also share ur view when it comes to logging in an EJB...but I have a basic doubt there also
EJB- spec does not encourage us to have static class level objects / variables...so inside EJBs how do we get a Category object...in other programs i get a static Category object with a unique name passed as a parameter. But what in case of an EJB? I feel that u shud not create a static class level instance of the category object?? any suggestions / comments..
 I have a thought but am not sure whether this will work...since log4j says that u get the same reference of the Category object when u call the getCategory() method from anywhere in the code, can we safely put the Category object as a non-static object inside the class?
Need help reg this concept esp when using log4j in EJBs..is there any article available for going thru reg log4j in EJBs??
Thanks in Advace,
Regards,
Ganapathi.
 
  "Diehl_Martin,_K�ln" <ma...@fja.com> wrote: Hi,

how does this interact with the transparent thread handling in an
EJB-Container.
In such a situation, when the container handles the threads that use my
classes, do I have to fear dead lock situations?

I think the only case where there could be a problem is when we call any
bean method inside the logging-call, which could be the case if the message
itself performs such a call to be evaluated.
E.g:
logger.info("Withdrawing " + amount + " $ from account " +
anotherBean.getAccountName(id));

The EJB-Spec prohibits 'the use of thread synchronization primitives', but
explains that this is due to the fact that the container may distribute my
beans over more than one address spaces. In that case we wouldn't have a
problem since we would als have more than one category hierarchies.

Any comment on that?


> -----Original Message-----
> From: Jon Skeet [SMTP:jon.skeet@peramon.com]
> Sent: Thursday, September 06, 2001 3:01 PM
> To: LOG4J Users Mailing List
> Subject: RE: Logging in a Multi threaded environment
> 
> > Currently we are considering log4j for our application 
> > logger and so I have tried out the basic features of log4j ....
> 
> > But i have a doubt when i try to log in a multithreaded 
> > environment...DOES log4j PROVIDE A SYNCHRONIZED LOGGING MECHANISM?? 
> 
> Yes - or rather, it depends on the appender in question, but any
> appender inheriting from AppenderSkeleton (which most will) synchronize
> there.
> 
> > say a thread A is logging some message in a class at 
> > the same time when another thread of the same class is 
> > also busy logging!! In such an event my HO is that since 
> > the Category object that they share is a static one with 
> > the same name, messages from both the threads would go to 
> > the same Category object..am i right?
> 
> Yes.
> 
> > Also, consider a situation wherein my thread A has a big 
> > message and has called its cat.info(message)...similarly 
> > thread B had called its cat.info(message) but has only a 
> > smaller message. In such a case, which will appear first, 
> > say in my file if i use a FileAppender, message of thread A or B???
> 
> Whichever gets to the appender.doAppend() first.
> 
> Jon
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: log4j-user-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org



---------------------------------
Do You Yahoo!?
Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger.